diff -r 308ab71207ff -r c828b61e0635 mercurial/dispatch.py --- a/mercurial/dispatch.py Tue Sep 02 11:28:44 2014 +0200 +++ b/mercurial/dispatch.py Tue Sep 09 13:47:50 2014 -0400 @@ -636,7 +636,12 @@ return path, lui -def _checkshellalias(lui, ui, args): +def _checkshellalias(lui, ui, args, precheck=True): + """Return the function to run the shell alias, if it is required + + 'precheck' is whether this function is invoked before adding + aliases or not. + """ options = {} try: @@ -647,18 +652,24 @@ if not args: return - norepo = commands.norepo - optionalrepo = commands.optionalrepo - def restorecommands(): - commands.norepo = norepo - commands.optionalrepo = optionalrepo - - cmdtable = commands.table.copy() - addaliases(lui, cmdtable) + if precheck: + strict = True + norepo = commands.norepo + optionalrepo = commands.optionalrepo + def restorecommands(): + commands.norepo = norepo + commands.optionalrepo = optionalrepo + cmdtable = commands.table.copy() + addaliases(lui, cmdtable) + else: + strict = False + def restorecommands(): + pass + cmdtable = commands.table cmd = args[0] try: - aliases, entry = cmdutil.findcmd(cmd, cmdtable) + aliases, entry = cmdutil.findcmd(cmd, cmdtable, strict) except (error.AmbiguousCommand, error.UnknownCommand): restorecommands() return @@ -715,6 +726,14 @@ addaliases(lui, commands.table) + if not lui.configbool("ui", "strict"): + # All aliases and commands are completely defined, now. + # Check abbreviation/ambiguity of shell alias again, because shell + # alias may cause failure of "_parse" (see issue4355) + shellaliasfn = _checkshellalias(lui, ui, args, precheck=False) + if shellaliasfn: + return shellaliasfn() + # check for fallback encoding fallback = lui.config('ui', 'fallbackencoding') if fallback: