changeset 9993:8bce1e0d2801 stable

alias: do not crash when aliased command has no usage help text
author Nicolas Dumazet <nicdumz.commits@gmail.com>
date Thu, 03 Dec 2009 14:14:44 +0900
parents 60cefb8b3c85
children 931d2c757627 eba6c8687fd2
files mercurial/dispatch.py tests/test-alias tests/test-alias.out
diffstat 3 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/dispatch.py	Wed Dec 02 14:30:39 2009 +0200
+++ b/mercurial/dispatch.py	Thu Dec 03 14:14:44 2009 +0900
@@ -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
--- a/tests/test-alias	Wed Dec 02 14:30:39 2009 +0200
+++ b/tests/test-alias	Thu Dec 03 14:14:44 2009 +0900
@@ -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
 
--- a/tests/test-alias.out	Wed Dec 02 14:30:39 2009 +0200
+++ b/tests/test-alias.out	Thu Dec 03 14:14:44 2009 +0900
@@ -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