mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 07:17:55 +03:00
cliparser: pass all arguments to expand_aliases
Summary: This gives `expand_aliases` a chance to handle things like `$1`, `$2`, etc. Related Python code assuming `expand_aliases` does not change args was removed. Reviewed By: kulshrax Differential Revision: D16530712 fbshipit-source-id: b81c2d29b9b9b5b93ce01627268a999a2cfd1ef0
This commit is contained in:
parent
5a36368ef8
commit
a9574245ca
@ -1049,7 +1049,7 @@ def _parse(ui, args):
|
||||
if args:
|
||||
try:
|
||||
replacement, aliases = cliparser.expandargs(
|
||||
ui._rcfg, commandnames, [args[0]], strict
|
||||
ui._rcfg, commandnames, args, strict
|
||||
)
|
||||
except cliparser.AmbiguousCommand as e:
|
||||
e.args[2].sort()
|
||||
@ -1073,8 +1073,13 @@ def _parse(ui, args):
|
||||
replace = idx
|
||||
break
|
||||
|
||||
fullargs = fullargs[:replace] + replacement + fullargs[replace + 1 :]
|
||||
replacement = replacement + args[1:]
|
||||
# FIXME: Find a way to avoid calling expandargs twice.
|
||||
fullargs = (
|
||||
fullargs[:replace]
|
||||
+ cliparser.expandargs(ui._rcfg, commandnames, fullargs[replace:], strict)[
|
||||
0
|
||||
]
|
||||
)
|
||||
|
||||
# Only need to figure out the command name. Parse result is dropped.
|
||||
cmd, _args, a, entry, level = cmdutil.findsubcmd(
|
||||
|
@ -400,14 +400,13 @@ impl Dispatcher {
|
||||
}
|
||||
}
|
||||
|
||||
let (expanded, _replaced) = expand_aliases(alias_lookup, &vec![first_arg.to_string()])
|
||||
let (expanded, _replaced) = expand_aliases(alias_lookup, &args[replace..])
|
||||
.map_err(|_| DispatchError::AliasExpansionFailed)?;
|
||||
|
||||
let mut new_args = Vec::new();
|
||||
|
||||
new_args.extend_from_slice(&args[..replace]);
|
||||
new_args.extend_from_slice(&expanded[..]);
|
||||
new_args.extend_from_slice(&args[replace + 1..]);
|
||||
|
||||
let command_name = self
|
||||
.find_command_name(expanded)
|
||||
|
Loading…
Reference in New Issue
Block a user