How to insert a bash script directly inside a Mercurial alias

I have a Mercurial alias that pushes the specified branch to the central repo:

[alias]
pushbranch = push -b

This works fine, but in 90% of cases I want to push the current branch, which I am doing now like this:

$ hg pushbranch `hg branch`

Although I could just update the alias in mine .hgrclike this:

[alias]
pushbranch = push -b `hg branch`

But this fails:

pushing to branch`
abort: unknown branch '`hg'!

I found this answer to accomplish essentially this with Git, but the mechanism used there also does not work with Mercurial, I did:

[alias]
pushbranch = push -b '!sh hg branch'

and received:

pushing to ssh://hg@bitbucket.org/myteam/reponame
abort: unknown branch '!hg branch'!

Any suggestions?

+4
source share
1 answer

Mercurial , . $HG Mercurial. :.

[alias]
pushbranch = !$HG push -b `$HG branch`
+4

All Articles