dispatch: make "_checkshellalias()" invoke "findcmd()" with "strict=True" stable
authorFUJIWARA Katsunori <foozy@lares.dti.ne.jp>
Wed, 29 Jan 2014 23:47:54 +0900
branchstable
changeset 20328 03d345da0579
parent 20327 46c2331fc750
child 20329 45f23b1ff345
dispatch: make "_checkshellalias()" invoke "findcmd()" with "strict=True" Before this patch, shell alias may be executed by abbreviated command name unexpectedly, even if abbreviated command name matches also against the command provided by extension. For example, "rebate" shell alias is executed by "hg reba", even if rebase extension (= "rebase" command) is enabled. In this case, "hg reba" should be aborted because of command name ambiguity. This patch makes "_checkshellalias()" invoke "cmdutil.findcmd()" always with "strict=True" (default value). If abbreviated command name matches against only one shell alias even after loading extensions, such shell alias will be executed via "_parse()". This patch doesn't remove "_checkshellalias()" invocation itself, because it may prevent shell alias from loading extensions uselessly.
mercurial/dispatch.py
tests/test-alias.t
--- a/mercurial/dispatch.py	Thu Jan 30 13:56:56 2014 -0600
+++ b/mercurial/dispatch.py	Wed Jan 29 23:47:54 2014 +0900
@@ -635,8 +635,7 @@
 
     cmd = args[0]
     try:
-        aliases, entry = cmdutil.findcmd(cmd, cmdtable,
-                                         lui.configbool("ui", "strict"))
+        aliases, entry = cmdutil.findcmd(cmd, cmdtable)
     except (error.AmbiguousCommand, error.UnknownCommand):
         restorecommands()
         return
--- a/tests/test-alias.t	Thu Jan 30 13:56:56 2014 -0600
+++ b/tests/test-alias.t	Wed Jan 29 23:47:54 2014 +0900
@@ -324,6 +324,21 @@
   $ hg escaped4 test
   $0 $@
 
+abbreviated name, which matches against both shell alias and the
+command provided extension, should be aborted.
+
+  $ cat >> .hg/hgrc <<EOF
+  > [extensions]
+  > hgext.rebase =
+  > [alias]
+  > rebate = !echo this is rebate
+  > EOF
+  $ hg reba
+  hg: command 'reba' is ambiguous:
+      rebase rebate
+  [255]
+  $ hg rebat
+  this is rebate
 
 invalid arguments