[PATCH] diff: Accept -u as a no-op in hg diff (issue2393)

Afuna afunamatata at gmail.com
Fri Feb 11 03:31:32 CST 2011


# HG changeset patch
# User Afuna
# Date 1297416680 -28800
# Node ID d282a65bec1b8a1866a04af48934442f016e69bb
# Parent  ddeb1074ee32c376e259e5a483545070d13f8e37
diff: Accept -u as a no-op in hg diff (issue2393)

The patch adds hg diff -u as a no-op. Since it looks weird to have -u in the full list of options, I've also modified the help command to ignore no-op options. They'll still show up on a -v.

Alternative is to detect commands with no long names, and not print them out if so, but I settled on this approach because it's more explicit.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -2186,6 +2186,8 @@ def help_(ui, name=None, with_version=Fa
                 shortopt, longopt, default, desc = option
                 optlabel = _("VALUE") # default label
 
+            if _("NO-OP") in desc and not ui.verbose:
+                continue
             if _("DEPRECATED") in desc and not ui.verbose:
                 continue
             if isinstance(default, list):
@@ -4172,6 +4174,7 @@ diffopts2 = [
      _('ignore changes whose lines are all blank')),
     ('U', 'unified', '',
      _('number of lines of context to show'), _('NUM')),
+    ('u', '', None, _('allows consistency with other diff tools (NO-OP)')),
     ('', 'stat', None, _('output diffstat-style summary of changes')),
 ]
 
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
@@ -83,6 +83,22 @@ invalid --unified
   +dd
    a
 
+with -u
+
+  $ hg diff --nodates -u
+  diff -r cf9f4ba66af2 a
+  --- a/a
+  +++ b/a
+  @@ -2,7 +2,7 @@
+   c
+   a
+   a
+  -b
+  +dd
+   a
+   a
+   c
+
 invalid diff.unified
 
   $ hg --config diff.unified=foo diff --nodates


More information about the Mercurial-devel mailing list