Submitter | Yuya Nishihara |
---|---|
Date | Aug. 14, 2014, 2:31 a.m. |
Message ID | <7ac2eadf1cbf8c630c2a.1407983488@mimosa> |
Download | mbox | patch |
Permalink | /patch/5392/ |
State | Accepted |
Headers | show |
Comments
On Thu, Aug 14, 2014 at 11:31:28AM +0900, Yuya Nishihara wrote: > # HG changeset patch > # User Yuya Nishihara <yuya@tcha.org> > # Date 1407936144 -32400 > # Wed Aug 13 22:22:24 2014 +0900 > # Node ID 7ac2eadf1cbf8c630c2abd38ab5f2e414ffe531f > # Parent 316511c7a08fbb84f8c6155832dc695e2ae8bb9e > alias: exit from bad definition by Abort Series looks like a nice improvement. Queued. Thanks! > > diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py > --- a/mercurial/dispatch.py > +++ b/mercurial/dispatch.py > @@ -425,16 +425,15 @@ class cmdalias(object): > > def __call__(self, ui, *args, **opts): > if self.badalias: > - ui.warn(self.badalias + '\n') > + hint = None > if self.unknowncmd: > try: > # check if the command is in a disabled extension > cmd, ext = extensions.disabledcmd(ui, self.cmdname)[:2] > - ui.warn(_("'%s' is provided by '%s' extension\n") > - % (cmd, ext)) > + hint = _("'%s' is provided by '%s' extension") % (cmd, ext) > except error.UnknownCommand: > pass > - return -1 > + raise util.Abort(self.badalias, hint=hint) > if self.shadows: > ui.debug("alias '%s' shadows command '%s'\n" % > (self.name, self.cmdname)) > 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 @@ basic > unknown > > $ hg unknown > - alias 'unknown' resolves to unknown command 'bargle' > + abort: alias 'unknown' resolves to unknown command 'bargle' > [255] > $ hg help unknown > alias 'unknown' resolves to unknown command 'bargle' > @@ -70,7 +70,7 @@ unknown > ambiguous > > $ hg ambiguous > - alias 'ambiguous' resolves to ambiguous command 's' > + abort: alias 'ambiguous' resolves to ambiguous command 's' > [255] > $ hg help ambiguous > alias 'ambiguous' resolves to ambiguous command 's' > @@ -79,7 +79,7 @@ ambiguous > recursive > > $ hg recursive > - alias 'recursive' resolves to unknown command 'recursive' > + abort: alias 'recursive' resolves to unknown command 'recursive' > [255] > $ hg help recursive > alias 'recursive' resolves to unknown command 'recursive' > @@ -88,8 +88,8 @@ recursive > disabled > > $ hg disabled > - alias 'disabled' resolves to unknown command 'email' > - 'email' is provided by 'patchbomb' extension > + abort: alias 'disabled' resolves to unknown command 'email' > + ('email' is provided by 'patchbomb' extension) > [255] > $ hg help disabled > alias 'disabled' resolves to unknown command 'email' > @@ -104,7 +104,7 @@ disabled > no definition > > $ hg nodef > - no definition for alias 'nodefinition' > + abort: no definition for alias 'nodefinition' > [255] > $ hg help nodef > no definition for alias 'nodefinition' > @@ -113,7 +113,7 @@ no definition > no closing quotation > > $ hg noclosing > - error in definition for alias 'noclosingquotation': No closing quotation > + abort: error in definition for alias 'noclosingquotation': No closing quotation > [255] > $ hg help noclosing > error in definition for alias 'noclosingquotation': No closing quotation > @@ -122,30 +122,30 @@ no closing quotation > invalid options > > $ hg no--cwd > - error in definition for alias 'no--cwd': --cwd may only be given on the command line > + abort: error in definition for alias 'no--cwd': --cwd may only be given on the command line > [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 > + abort: error in definition for alias 'no-R': -R may only be given on the command line > [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 > + abort: error in definition for alias 'no--repo': --repo may only be given on the command line > [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 > + abort: error in definition for alias 'no--repository': --repository may only be given on the command line > [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 > + abort: error in definition for alias 'no--config': --config may only be given on the command line > [255] > > optional repository > _______________________________________________ > Mercurial-devel mailing list > Mercurial-devel@selenic.com > http://selenic.com/mailman/listinfo/mercurial-devel
Patch
diff --git a/mercurial/dispatch.py b/mercurial/dispatch.py --- a/mercurial/dispatch.py +++ b/mercurial/dispatch.py @@ -425,16 +425,15 @@ class cmdalias(object): def __call__(self, ui, *args, **opts): if self.badalias: - ui.warn(self.badalias + '\n') + hint = None if self.unknowncmd: try: # check if the command is in a disabled extension cmd, ext = extensions.disabledcmd(ui, self.cmdname)[:2] - ui.warn(_("'%s' is provided by '%s' extension\n") - % (cmd, ext)) + hint = _("'%s' is provided by '%s' extension") % (cmd, ext) except error.UnknownCommand: pass - return -1 + raise util.Abort(self.badalias, hint=hint) if self.shadows: ui.debug("alias '%s' shadows command '%s'\n" % (self.name, self.cmdname)) 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 @@ basic unknown $ hg unknown - alias 'unknown' resolves to unknown command 'bargle' + abort: alias 'unknown' resolves to unknown command 'bargle' [255] $ hg help unknown alias 'unknown' resolves to unknown command 'bargle' @@ -70,7 +70,7 @@ unknown ambiguous $ hg ambiguous - alias 'ambiguous' resolves to ambiguous command 's' + abort: alias 'ambiguous' resolves to ambiguous command 's' [255] $ hg help ambiguous alias 'ambiguous' resolves to ambiguous command 's' @@ -79,7 +79,7 @@ ambiguous recursive $ hg recursive - alias 'recursive' resolves to unknown command 'recursive' + abort: alias 'recursive' resolves to unknown command 'recursive' [255] $ hg help recursive alias 'recursive' resolves to unknown command 'recursive' @@ -88,8 +88,8 @@ recursive disabled $ hg disabled - alias 'disabled' resolves to unknown command 'email' - 'email' is provided by 'patchbomb' extension + abort: alias 'disabled' resolves to unknown command 'email' + ('email' is provided by 'patchbomb' extension) [255] $ hg help disabled alias 'disabled' resolves to unknown command 'email' @@ -104,7 +104,7 @@ disabled no definition $ hg nodef - no definition for alias 'nodefinition' + abort: no definition for alias 'nodefinition' [255] $ hg help nodef no definition for alias 'nodefinition' @@ -113,7 +113,7 @@ no definition no closing quotation $ hg noclosing - error in definition for alias 'noclosingquotation': No closing quotation + abort: error in definition for alias 'noclosingquotation': No closing quotation [255] $ hg help noclosing error in definition for alias 'noclosingquotation': No closing quotation @@ -122,30 +122,30 @@ no closing quotation invalid options $ hg no--cwd - error in definition for alias 'no--cwd': --cwd may only be given on the command line + abort: error in definition for alias 'no--cwd': --cwd may only be given on the command line [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 + abort: error in definition for alias 'no-R': -R may only be given on the command line [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 + abort: error in definition for alias 'no--repo': --repo may only be given on the command line [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 + abort: error in definition for alias 'no--repository': --repository may only be given on the command line [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 + abort: error in definition for alias 'no--config': --config may only be given on the command line [255] optional repository