[PATCH 2b of 2 STABLE] cmdutil: prevent "show" from matching "showconfig" (BC)
Gregory Szorc
gregory.szorc at gmail.com
Thu Apr 27 19:08:51 EDT 2017
# HG changeset patch
# User Gregory Szorc <gregory.szorc at gmail.com>
# Date 1493334180 25200
# Thu Apr 27 16:03:00 2017 -0700
# Branch stable
# Node ID f86d46196e44f3a7387657de4689058dbb8e0567
# Parent f495df1ca1cc3583ecfbed208de69a966eb74aea
cmdutil: prevent "show" from matching "showconfig" (BC)
`hg show` is provided by the "show" extension.
`hg config` has a "showconfig" alias.
In a vanilla installation, if you run `hg show`, `hg showconfig` runs.
This can be a bit confusing. If you e.g. `hg show work` you'll (almost
certainly) get no output and an exit code of 1.
This (hacky) commit changes the alias matching code to exclude
"show" from mapping to "showconfig." It is a minimal change to
make the out-of-the-box behavior of `hg show` more reasonable.
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -318,9 +318,17 @@ def findpossible(cmd, table, strict=Fals
found = cmd
elif not strict:
for a in aliases:
- if a.startswith(cmd):
- found = a
- break
+ if not a.startswith(cmd):
+ continue
+
+ # TODO remove this hack once show extension is merged into
+ # core. And/or consider a @command argument to define unwanted
+ # matches.
+ if cmd == 'show' and a == 'showconfig':
+ continue
+
+ found = a
+ break
if found is not None:
if aliases[0].startswith("debug") or found.startswith("debug"):
debugchoice[found] = (aliases, table[e])
diff --git a/tests/test-show.t b/tests/test-show.t
--- a/tests/test-show.t
+++ b/tests/test-show.t
@@ -2,18 +2,14 @@
TODO this is broken due to matching with showconfig
$ hg show
- defaults.backout=-d "0 0"
- defaults.commit=-d "0 0"
- defaults.shelve=--date "0 0"
- defaults.tag=-d "0 0"
- devel.all-warnings=true
- largefiles.usercache=$TESTTMP/.cache/largefiles
- ui.slash=True
- ui.interactive=False
- ui.mergemarkers=detailed
- ui.promptecho=True
- web.address=localhost
- web.ipv6=False
+ hg: unknown command 'show'
+ 'show' is provided by the following extension:
+
+ show unified command to show various repository information
+ (EXPERIMENTAL)
+
+ (use 'hg help extensions' for information on enabling extensions)
+ [255]
$ cat >> $HGRCPATH << EOF
> [extensions]
More information about the Mercurial-devel
mailing list