mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 23:38:50 +03:00
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".
This commit is contained in:
parent
ca3e00a8e3
commit
906133d681
@ -627,7 +627,12 @@ def _getlocal(ui, rpath):
|
||||
|
||||
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 @@ def _checkshellalias(lui, ui, args):
|
||||
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:
|
||||
|
Loading…
Reference in New Issue
Block a user