alias: change return code of bad definition to 255 stable
authorYuya Nishihara <yuya@tcha.org>
Sat, 17 May 2014 15:14:18 +0900
branchstable
changeset 21572 6c9b7712ac69
parent 21571 17da326fd041
child 21581 341039aa1154
alias: change return code of bad definition to 255 We use 255 for general command error. It can't raise util.Abort because help module executes badalias command to get error message.
mercurial/dispatch.py
tests/test-alias.t
--- a/mercurial/dispatch.py	Tue May 27 15:16:52 2014 -0700
+++ b/mercurial/dispatch.py	Sat May 17 15:14:18 2014 +0900
@@ -355,7 +355,7 @@
         if not self.definition:
             def fn(ui, *args):
                 ui.warn(_("no definition for alias '%s'\n") % self.name)
-                return 1
+                return -1
             self.fn = fn
             self.badalias = True
             return
@@ -389,7 +389,7 @@
             def fn(ui, *args):
                 ui.warn(_("error in definition for alias '%s': %s\n")
                         % (self.name, inst))
-                return 1
+                return -1
             self.fn = fn
             self.badalias = True
             return
@@ -402,7 +402,7 @@
                     ui.warn(_("error in definition for alias '%s': %s may only "
                               "be given on the command line\n")
                             % (self.name, invalidarg))
-                    return 1
+                    return -1
 
                 self.fn = fn
                 self.badalias = True
@@ -434,14 +434,14 @@
                     commands.help_(ui, cmd, unknowncmd=True)
                 except error.UnknownCommand:
                     pass
-                return 1
+                return -1
             self.fn = fn
             self.badalias = True
         except error.AmbiguousCommand:
             def fn(ui, *args):
                 ui.warn(_("alias '%s' resolves to ambiguous command '%s'\n") \
                             % (self.name, cmd))
-                return 1
+                return -1
             self.fn = fn
             self.badalias = True
 
--- a/tests/test-alias.t	Tue May 27 15:16:52 2014 -0700
+++ b/tests/test-alias.t	Sat May 17 15:14:18 2014 +0900
@@ -61,7 +61,7 @@
 
   $ hg unknown
   alias 'unknown' resolves to unknown command 'bargle'
-  [1]
+  [255]
   $ hg help unknown
   alias 'unknown' resolves to unknown command 'bargle'
 
@@ -70,7 +70,7 @@
 
   $ hg ambiguous
   alias 'ambiguous' resolves to ambiguous command 's'
-  [1]
+  [255]
   $ hg help ambiguous
   alias 'ambiguous' resolves to ambiguous command 's'
 
@@ -79,7 +79,7 @@
 
   $ hg recursive
   alias 'recursive' resolves to unknown command 'recursive'
-  [1]
+  [255]
   $ hg help recursive
   alias 'recursive' resolves to unknown command 'recursive'
 
@@ -88,7 +88,7 @@
 
   $ hg nodef
   no definition for alias 'nodefinition'
-  [1]
+  [255]
   $ hg help nodef
   no definition for alias 'nodefinition'
 
@@ -97,7 +97,7 @@
 
   $ hg noclosing
   error in definition for alias 'noclosingquotation': No closing quotation
-  [1]
+  [255]
   $ hg help noclosing
   error in definition for alias 'noclosingquotation': No closing quotation
 
@@ -106,27 +106,27 @@
 
   $ hg no--cwd
   error in definition for alias 'no--cwd': --cwd may only be given on the command line
-  [1]
+  [255]
   $ hg help no--cwd
   error in definition for alias 'no--cwd': --cwd may only be given on the command line
   $ hg no-R
   error in definition for alias 'no-R': -R may only be given on the command line
-  [1]
+  [255]
   $ hg help no-R
   error in definition for alias 'no-R': -R may only be given on the command line
   $ hg no--repo
   error in definition for alias 'no--repo': --repo may only be given on the command line
-  [1]
+  [255]
   $ hg help no--repo
   error in definition for alias 'no--repo': --repo may only be given on the command line
   $ hg no--repository
   error in definition for alias 'no--repository': --repository may only be given on the command line
-  [1]
+  [255]
   $ hg help no--repository
   error in definition for alias 'no--repository': --repository may only be given on the command line
   $ hg no--config
   error in definition for alias 'no--config': --config may only be given on the command line
-  [1]
+  [255]
 
 optional repository