Patchwork [6,of,8,V2] diff: add a --noprefix option

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

Comments

Siddharth Agarwal - Nov. 13, 2014, 11:08 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1415866428 28800
#      Thu Nov 13 00:13:48 2014 -0800
# Node ID d7fcdbb45b8e76c527d6f45a3bba37135b9aefe1
# Parent  367aac327b958b034ceae7629e7fa1fd95c14ec6
diff: add a --noprefix option

See previous patch descriptions for the motivation.

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/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -141,6 +141,7 @@ 
     ]
 
 diffopts2 = [
+    ('', 'noprefix', None, _('omit a/ and b/ prefixes from filenames')),
     ('p', 'show-function', None, _('show which function each change is in')),
     ('', 'reverse', None, _('produce a diff that undoes the changes')),
     ] + diffwsopts + [
diff --git a/tests/test-completion.t b/tests/test-completion.t
--- a/tests/test-completion.t
+++ b/tests/test-completion.t
@@ -202,7 +202,7 @@ 
   annotate: rev, follow, no-follow, text, user, file, date, number, changeset, line-number, ignore-all-space, ignore-space-change, ignore-blank-lines, include, exclude, template
   clone: noupdate, updaterev, rev, branch, pull, uncompressed, ssh, remotecmd, insecure
   commit: addremove, close-branch, amend, secret, edit, include, exclude, message, logfile, date, user, subrepos
-  diff: rev, change, text, git, nodates, show-function, reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, unified, stat, include, exclude, subrepos
+  diff: rev, change, text, git, nodates, noprefix, show-function, reverse, ignore-all-space, ignore-space-change, ignore-blank-lines, unified, stat, include, exclude, subrepos
   export: output, switch-parent, rev, text, git, nodates
   forget: include, exclude
   init: ssh, remotecmd, insecure
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,7 +89,7 @@ 
   abort: diff context lines count must be an integer, not 'foo'
   [255]
 
-noprefix config
+noprefix config and option
 
   $ hg --config diff.noprefix=True diff --nodates
   diff -r cf9f4ba66af2 a
@@ -104,8 +104,21 @@ 
    a
    a
    c
+  $ hg diff --noprefix --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
+noprefix config disabled in plain mode, but option still enabled
 
   $ HGPLAIN=1 hg --config diff.noprefix=True diff --nodates
   diff -r cf9f4ba66af2 a
@@ -120,6 +133,19 @@ 
    a
    a
    c
+  $ HGPLAIN=1 hg diff --noprefix --nodates
+  diff -r cf9f4ba66af2 a
+  --- a/a
+  +++ b/a
+  @@ -2,7 +2,7 @@
+   c
+   a
+   a
+  -b
+  +dd
+   a
+   a
+   c
 
   $ cd ..
 
@@ -215,7 +241,7 @@ 
   -a
   +b
 
-noprefix config disabled in plain mode
+noprefix config disabled in plain mode, but option still enabled
 
   $ HGPLAIN=1 hg --config diff.noprefix=True diff --git --nodates
   diff --git a/f1 b/f 1
@@ -226,6 +252,15 @@ 
   @@ -1,1 +1,1 @@
   -a
   +b
+  $ HGPLAIN=1 hg diff --git --noprefix --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
 
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -500,6 +500,7 @@ 
    -a --text                treat all files as text
    -g --git                 use git extended diff format
       --nodates             omit dates from diff headers
+      --noprefix            omit a/ and b/ prefixes from filenames
    -p --show-function       show which function each change is in
       --reverse             produce a diff that undoes the changes
    -w --ignore-all-space    ignore white space when comparing lines