# HG changeset patch # User FUJIWARA Katsunori # Date 1410277304 -32400 # Node ID d821fff9b0b95d75859f24f631872f0e903f4d2c # Parent 802dffd62de5a7649b83edfcde6960a8d92efedc dispatch: make "_checkshellalias" reusable regardless of adding aliases To reduce changes in the subsequent patch fixing issue4355, this patch makes "_checkshellalias" reusable regardless of adding aliases. In this patch, alias definitions are added and restored, only when "precheck=True". diff -r 802dffd62de5 -r d821fff9b0b9 mercurial/dispatch.py --- a/mercurial/dispatch.py Wed Sep 03 20:42:51 2014 +0200 +++ b/mercurial/dispatch.py Wed Sep 10 00:41:44 2014 +0900 @@ -627,7 +627,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: @@ -638,14 +643,18 @@ 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: + norepo = commands.norepo + optionalrepo = commands.optionalrepo + def restorecommands(): + commands.norepo = norepo + commands.optionalrepo = optionalrepo + cmdtable = commands.table.copy() + addaliases(lui, cmdtable) + else: + def restorecommands(): + pass + cmdtable = commands.table cmd = args[0] try: