alias: abort on missing positional args (issue3331) stable
authorMatt Mackall <mpm@selenic.com>
Tue, 27 Mar 2012 16:13:59 -0500
branchstable
changeset 16294 795d591b6ef5
parent 16293 bc1d949261c4
child 16295 ba42eb722bb3
child 16296 4343d5226149
child 16311 cb17c2f5b7b4
alias: abort on missing positional args (issue3331)
mercurial/dispatch.py
tests/test-alias.t
--- a/mercurial/dispatch.py	Wed Feb 15 17:30:21 2012 -0500
+++ b/mercurial/dispatch.py	Tue Mar 27 16:13:59 2012 -0500
@@ -218,7 +218,7 @@
 
 def aliasargs(fn, givenargs):
     args = getattr(fn, 'args', [])
-    if args and givenargs:
+    if args:
         cmd = ' '.join(map(util.shellquote, args))
 
         nums = []
@@ -227,7 +227,7 @@
             nums.append(num)
             if num < len(givenargs):
                 return givenargs[num]
-            return ''
+            raise util.Abort(_('too few arguments for command alias'))
         cmd = re.sub(r'\$(\d+|\$)', replacer, cmd)
         givenargs = [x for i, x in enumerate(givenargs)
                      if i not in nums]
--- a/tests/test-alias.t	Wed Feb 15 17:30:21 2012 -0500
+++ b/tests/test-alias.t	Tue Mar 27 16:13:59 2012 -0500
@@ -134,6 +134,12 @@
 
 positional arguments
 
+  $ hg positional
+  abort: too few arguments for command alias
+  [255]
+  $ hg positional a
+  abort: too few arguments for command alias
+  [255]
   $ hg positional 'node|short' rev
   0 e63c23eaa88a | 1970-01-01 00:00 +0000