Patchwork [8,of,8,V2] patch.trydiff: add support for noprefix

login
register
mail settings
Submitter Siddharth Agarwal
Date Nov. 13, 2014, 11:08 p.m.
Message ID <1e93f17982d3c8ebdc81.1415920133@devbig136.prn2.facebook.com>
Download mbox | patch
Permalink /patch/6720/
State Accepted
Commit f8b5c3e77d4b8d92d6085d45d7193433c85cc0ee
Headers show

Comments

Siddharth Agarwal - Nov. 13, 2014, 11:08 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1415865021 28800
#      Wed Nov 12 23:50:21 2014 -0800
# Node ID 1e93f17982d3c8ebdc81867756540e52883c9ad4
# Parent  4b1e69979d7496f518ddd6a496cf45cfb212987f
patch.trydiff: add support for noprefix
Matt Mackall - Nov. 13, 2014, 11:32 p.m.
On Thu, 2014-11-13 at 15:08 -0800, Siddharth Agarwal wrote:
> # HG changeset patch
> # User Siddharth Agarwal <sid0@fb.com>
> # Date 1415865021 28800
> #      Wed Nov 12 23:50:21 2014 -0800
> # Node ID 1e93f17982d3c8ebdc81867756540e52883c9ad4
> # Parent  4b1e69979d7496f518ddd6a496cf45cfb212987f
> patch.trydiff: add support for noprefix

These are queued for default, thanks.

Patch

diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -1738,9 +1738,15 @@ 
         s.update(text)
         return s.hexdigest()
 
+    if opts.noprefix:
+        aprefix = bprefix = ''
+    else:
+        aprefix = 'a/'
+        bprefix = 'b/'
+
     def diffline(a, b, revs):
         if opts.git:
-            line = 'diff --git a/%s b/%s\n' % (a, b)
+            line = 'diff --git %s%s %s%s\n' % (aprefix, a, bprefix, b)
         elif not repo.ui.quiet:
             if revs:
                 revinfo = ' '.join(["-r %s" % rev for rev in revs])
diff --git a/tests/test-diff-unified.t b/tests/test-diff-unified.t
--- a/tests/test-diff-unified.t
+++ b/tests/test-diff-unified.t
@@ -232,7 +232,7 @@ 
 Git diff with noprefix
 
   $ hg --config diff.noprefix=True diff --git --nodates
-  diff --git a/f1 b/f 1
+  diff --git f1 f 1
   rename from f1
   rename to f 1
   --- f1
@@ -253,7 +253,7 @@ 
   -a
   +b
   $ HGPLAIN=1 hg diff --git --noprefix --nodates
-  diff --git a/f1 b/f 1
+  diff --git f1 f 1
   rename from f1
   rename to f 1
   --- f1