Patchwork [2b,of,2,STABLE] cmdutil: prevent "show" from matching "showconfig" (BC)

login
register
mail settings
Submitter Gregory Szorc
Date April 27, 2017, 11:08 p.m.
Message ID <f86d46196e44f3a73876.1493334531@ubuntu-vm-main>
Download mbox | patch
Permalink /patch/20308/
State Deferred
Headers show

Comments

Gregory Szorc - April 27, 2017, 11:08 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@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.

Patch

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]