# HG changeset patch # User Yuya Nishihara # Date 2014-05-17 06:14:18 # Node ID 6c9b7712ac69647b8979e5987c59f6db3f4925bd # Parent 17da326fd0412e045c4d7a8f89ca69bfb83bdca3 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. diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py --- a/mercurial/dispatch.py +++ b/mercurial/dispatch.py @@ -355,7 +355,7 @@ class cmdalias(object): 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 @@ class cmdalias(object): 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 @@ class cmdalias(object): 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 @@ class cmdalias(object): 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 diff --git a/tests/test-alias.t b/tests/test-alias.t --- a/tests/test-alias.t +++ b/tests/test-alias.t @@ -61,7 +61,7 @@ unknown $ 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 @@ ambiguous $ 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 @@ recursive $ 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 @@ no definition $ hg nodef no definition for alias 'nodefinition' - [1] + [255] $ hg help nodef no definition for alias 'nodefinition' @@ -97,7 +97,7 @@ no closing quotation $ 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 @@ invalid options $ 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