问题
I want to create an alias so that when I run:
hg pushbranch <<SOME_BRANCH>>
it aliases to:
hg push -b <<SOME_BRANCH>>
Where SOME_BRANCH
is the name of a branch I wish to push. I can create an alias in my .hgrc
, but don't know how I could supply an argument to the alias.
回答1:
From the hgrc help
Positional arguments in the form of $1, $2, etc in the alias definition are expanded by Mercurial before execution.
Thus, your alias definition, which will allow to push any branch, will be
pushbranch = push -b $1
and hg pushbranch mybranch
is expanded to hg push -b mybranch
回答2:
You can simply add the arguments in your alias. Some examples from my configuration:
[alias]
log0 = log -l 10
tipr = tip --template "{node|short}"
If you provide additional arguments, they'll simply be appended. For example, the following will be functionally equivalent to log -l 10 -k Refactoring
.
$ hg log0 -k Refactoring
来源:https://stackoverflow.com/questions/31009414/mercurial-alias-with-arguments