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

login
register
mail settings
Submitter Siddharth Agarwal
Date Nov. 13, 2014, 11:08 p.m.
Message ID <367aac327b958b034cea.1415920130@devbig136.prn2.facebook.com>
Download mbox | patch
Permalink /patch/6718/
State Accepted
Commit d7abae94a7a0de48b20b5516a0e438c190cdf738
Headers show

Comments

Siddharth Agarwal - Nov. 13, 2014, 11:08 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1415866124 28800
#      Thu Nov 13 00:08:44 2014 -0800
# Node ID 367aac327b958b034ceae7629e7fa1fd95c14ec6
# Parent  6a40a01c1b5ce0a4edb972ca42bfcb2e791e48fe
patch.diffopts: add support for noprefix

In an upcoming patch we'll enable support as an option to 'hg diff' as well.

The tests reflect the current state of the world -- as we add support we'll see
changes in the test output.

Patch

diff --git a/mercurial/help/config.txt b/mercurial/help/config.txt
--- a/mercurial/help/config.txt
+++ b/mercurial/help/config.txt
@@ -547,6 +547,9 @@ 
 ``nodates``
     Don't include dates in diff headers.
 
+``noprefix``
+    Omit 'a/' and 'b/' prefixes from filenames. Ignored in plain mode.
+
 ``showfunc``
     Show which function each change is in.
 
diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -1573,6 +1573,7 @@ 
         git=get('git'),
         nodates=get('nodates'),
         nobinary=get('nobinary'),
+        noprefix=get('noprefix', forceplain=False),
         showfunc=get('show_function', 'showfunc'),
         ignorews=get('ignore_all_space', 'ignorews'),
         ignorewsamount=get('ignore_space_change', 'ignorewsamount'),
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
@@ -89,6 +89,38 @@ 
   abort: diff context lines count must be an integer, not 'foo'
   [255]
 
+noprefix config
+
+  $ hg --config diff.noprefix=True diff --nodates
+  diff -r cf9f4ba66af2 a
+  --- a/a
+  +++ b/a
+  @@ -2,7 +2,7 @@
+   c
+   a
+   a
+  -b
+  +dd
+   a
+   a
+   c
+
+noprefix disabled in plain mode
+
+  $ HGPLAIN=1 hg --config diff.noprefix=True diff --nodates
+  diff -r cf9f4ba66af2 a
+  --- a/a
+  +++ b/a
+  @@ -2,7 +2,7 @@
+   c
+   a
+   a
+  -b
+  +dd
+   a
+   a
+   c
+
   $ cd ..
 
 
@@ -171,6 +203,30 @@ 
   -a
   +b
 
+Git diff with noprefix
+
+  $ hg --config diff.noprefix=True diff --git --nodates
+  diff --git a/f1 b/f 1
+  rename from f1
+  rename to f 1
+  --- a/f1
+  +++ b/f 1	
+  @@ -1,1 +1,1 @@
+  -a
+  +b
+
+noprefix config disabled in plain mode
+
+  $ HGPLAIN=1 hg --config diff.noprefix=True diff --git --nodates
+  diff --git a/f1 b/f 1
+  rename from f1
+  rename to f 1
+  --- a/f1
+  +++ b/f 1	
+  @@ -1,1 +1,1 @@
+  -a
+  +b
+
 Regular diff --nodates, file deletion
 
   $ hg ci -m addspace