How (is it possible) to create an hg command alias that runs multiple commands?

ぃ、小莉子 提交于 2019-12-18 18:56:08

问题


I would like to define a Mercurial command alias in my hgrc file that invokes multiple commands. For example I would like to do something like the following:

[alias]
giveup = revert --all --no-backup; purge
syncprod = fetch production; push production

This would allow me to call hg syncprod and have it invoke a fetch and then a push. Haven't been able to determine if this capability exists. (I'm guessing that means no.)


回答1:


Use the shell alias style like this:

giveup = !$HG revert --all --no-backup ; $HG purge

Though, personally I'd just create a bash alias for those so I could skip the hg part altogether.




回答2:


I'm unable to comment on the previous answer, but for anyone else looking to do this on Windows, the following syntax worked for me, without having to use PowerShell or cygwin.

giveup = !hg revert --all --no-backup && hg purge

Alternatively, this version will execute the purge regardless of whether the revert was successful:

giveup = !hg revert --all --no-backup & hg purge

It is possible to string together more than two commands, for instance:

shebase = !hg shelve && hg rebase && hg unshelve


来源:https://stackoverflow.com/questions/5098085/how-is-it-possible-to-create-an-hg-command-alias-that-runs-multiple-commands

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!