# HG changeset patch # User Yuya Nishihara # Date 1400299576 -32400 # Node ID c5afb07c33d3fe99c9e3c60a24e44ac4ae5b9f9e # Parent 8dd17b19e722209693c786f1c3c318a1dab05086 alias: handle shlex error in command aliases No command should fail with ValueError just because there is unparseable alias definition. It returns 1 like other badalias handlers, but should be changed to 255 in a later version because we use 255 for general command error. diff -r 8dd17b19e722 -r c5afb07c33d3 mercurial/dispatch.py --- a/mercurial/dispatch.py Thu May 08 19:03:00 2014 +0900 +++ b/mercurial/dispatch.py Sat May 17 13:06:16 2014 +0900 @@ -383,7 +383,16 @@ self.fn = fn return - args = shlex.split(self.definition) + try: + args = shlex.split(self.definition) + except ValueError, inst: + def fn(ui, *args): + ui.warn(_("error in definition for alias '%s': %s\n") + % (self.name, inst)) + return 1 + self.fn = fn + self.badalias = True + return self.cmdname = cmd = args.pop(0) args = map(util.expandpath, args) diff -r 8dd17b19e722 -r c5afb07c33d3 tests/test-alias.t --- a/tests/test-alias.t Thu May 08 19:03:00 2014 +0900 +++ b/tests/test-alias.t Sat May 17 13:06:16 2014 +0900 @@ -11,6 +11,7 @@ > ambiguous = s > recursive = recursive > nodefinition = + > noclosingquotation = ' > no--cwd = status --cwd elsewhere > no-R = status -R elsewhere > no--repo = status --repo elsewhere @@ -92,6 +93,15 @@ no definition for alias 'nodefinition' +no closing quotation + + $ hg noclosing + error in definition for alias 'noclosingquotation': No closing quotation + [1] + $ hg help noclosing + error in definition for alias 'noclosingquotation': No closing quotation + + invalid options $ hg no--cwd