Patchwork [1,of,7] patchbomb: don't honor whitespace and format-changing diffopts

login
register
mail settings
Submitter Siddharth Agarwal
Date Dec. 2, 2014, 6:30 p.m.
Message ID <9d4aa97bc4664d9e0168.1417545012@devbig136.prn2.facebook.com>
Download mbox | patch
Permalink /patch/6952/
State Accepted
Commit 007be973e7b9a238d224cbc37b53c8c14f23e87f
Headers show

Comments

Siddharth Agarwal - Dec. 2, 2014, 6:30 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1416360984 28800
#      Tue Nov 18 17:36:24 2014 -0800
# Node ID 9d4aa97bc4664d9e016894794c1893e59217922e
# Parent  716d9ab5c1424496bea3802cef94283f752d7122
patchbomb: don't honor whitespace and format-changing diffopts

The whitespace diffopts break lossless transmission, and the format-changing
ones make import harder. We expect parsers to be able to read git-style diffs,
though.

Patch

diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py
--- a/hgext/patchbomb.py
+++ b/hgext/patchbomb.py
@@ -166,7 +166,7 @@ 
                       'uncommitted changes\n'))
         output = cStringIO.StringIO()
         cmdutil.export(repo, [r], fp=output,
-                     opts=patch.diffopts(ui, opts))
+                     opts=patch.difffeatureopts(ui, opts, git=True))
         yield output.getvalue().split('\n')
 def _getbundle(repo, dest, **opts):
     """return a bundle containing changesets missing in "dest"
diff --git a/tests/test-patchbomb.t b/tests/test-patchbomb.t
--- a/tests/test-patchbomb.t
+++ b/tests/test-patchbomb.t
@@ -86,6 +86,80 @@ 
   abort: patchbomb canceled
   [255]
 
+Test diff.git is respected
+  $ hg --config diff.git=True email --date '1970-1-1 0:1' -n -f quux -t foo -c bar -r tip
+  this patch series consists of 1 patches.
+  
+  
+  displaying [PATCH] a ...
+  Content-Type: text/plain; charset="us-ascii"
+  MIME-Version: 1.0
+  Content-Transfer-Encoding: 7bit
+  Subject: [PATCH] a
+  X-Mercurial-Node: 8580ff50825a50c8f716709acdf8de0deddcd6ab
+  X-Mercurial-Series-Index: 1
+  X-Mercurial-Series-Total: 1
+  Message-Id: <8580ff50825a50c8f716.60@*> (glob)
+  X-Mercurial-Series-Id: <8580ff50825a50c8f716.60@*> (glob)
+  User-Agent: Mercurial-patchbomb/* (glob)
+  Date: Thu, 01 Jan 1970 00:01:00 +0000
+  From: quux
+  To: foo
+  Cc: bar
+  
+  # HG changeset patch
+  # User test
+  # Date 1 0
+  #      Thu Jan 01 00:00:01 1970 +0000
+  # Node ID 8580ff50825a50c8f716709acdf8de0deddcd6ab
+  # Parent  0000000000000000000000000000000000000000
+  a
+  
+  diff --git a/a b/a
+  new file mode 100644
+  --- /dev/null
+  +++ b/a
+  @@ -0,0 +1,1 @@
+  +a
+  
+
+
+Test breaking format changes aren't
+  $ hg --config diff.noprefix=True email --date '1970-1-1 0:1' -n -f quux -t foo -c bar -r tip
+  this patch series consists of 1 patches.
+  
+  
+  displaying [PATCH] a ...
+  Content-Type: text/plain; charset="us-ascii"
+  MIME-Version: 1.0
+  Content-Transfer-Encoding: 7bit
+  Subject: [PATCH] a
+  X-Mercurial-Node: 8580ff50825a50c8f716709acdf8de0deddcd6ab
+  X-Mercurial-Series-Index: 1
+  X-Mercurial-Series-Total: 1
+  Message-Id: <8580ff50825a50c8f716.60@*> (glob)
+  X-Mercurial-Series-Id: <8580ff50825a50c8f716.60@*> (glob)
+  User-Agent: Mercurial-patchbomb/* (glob)
+  Date: Thu, 01 Jan 1970 00:01:00 +0000
+  From: quux
+  To: foo
+  Cc: bar
+  
+  # HG changeset patch
+  # User test
+  # Date 1 0
+  #      Thu Jan 01 00:00:01 1970 +0000
+  # Node ID 8580ff50825a50c8f716709acdf8de0deddcd6ab
+  # Parent  0000000000000000000000000000000000000000
+  a
+  
+  diff -r 000000000000 -r 8580ff50825a a
+  --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+  +++ b/a	Thu Jan 01 00:00:01 1970 +0000
+  @@ -0,0 +1,1 @@
+  +a
+  
+
   $ echo b > b
   $ hg commit -Amb -d '2 0'
   adding b