[PATCH STABLE] alias: do not crash when aliased command has no usage help text

Nicolas Dumazet nicdumz at gmail.com
Wed Dec 2 23:20:36 CST 2009


# HG changeset patch
# User Nicolas Dumazet <nicdumz.commits at gmail.com>
# Date 1259817284 -32400
# Node ID d4737e35527c847bbd86091f846403560f764b97
# Parent  e97dd3a8e8d70450dce7b0a0dc8d420ea1d0bbc3
alias: do not crash when aliased command has no usage help text

diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py
--- a/mercurial/dispatch.py
+++ b/mercurial/dispatch.py
@@ -196,7 +196,12 @@
         cmd = args.pop(0)
 
         try:
-            self.fn, self.opts, self.help = cmdutil.findcmd(cmd, cmdtable, False)[1]
+            tableentry = cmdutil.findcmd(cmd, cmdtable, False)[1]
+            if len(tableentry) > 2:
+                self.fn, self.opts, self.help = tableentry
+            else:
+                self.fn, self.opts = tableentry
+
             self.args = aliasargs(self.fn) + args
             if cmd not in commands.norepo.split(' '):
                 self.norepo = False
diff --git a/tests/test-alias b/tests/test-alias
--- a/tests/test-alias
+++ b/tests/test-alias
@@ -12,6 +12,7 @@
 lognull = log -r null
 shortlog = log --template '{rev} {node|short} | {date|isodate}\n'
 dln = lognull --debug
+nousage = rollback
 
 [defaults]
 mylog = -q
@@ -35,6 +36,10 @@
 hg nodef
 
 cd alias
+
+echo '% no usage'
+hg nousage
+
 echo foo > foo
 hg ci -Amfoo
 
diff --git a/tests/test-alias.out b/tests/test-alias.out
--- a/tests/test-alias.out
+++ b/tests/test-alias.out
@@ -7,6 +7,8 @@
 alias 'recursive' resolves to unknown command 'recursive'
 % no definition
 no definition for alias 'nodefinition'
+% no usage
+no rollback information available
 adding foo
 % with opts
 C foo


More information about the Mercurial-devel mailing list