Push to multiple remote repositories from a single local repo in Mercurial

纵饮孤独 提交于 2019-12-03 04:23:06

You can set multiple remote repository aliases in the [paths] section of the repository configuration file. This file is in .hg/hgrc, and you would add paths like this

[paths]
default = http://kilnhg.com/repo
bitbucket = http://bitbucket.org/repo

Then you would run hg push bitbucket to push to bitbucket and hg push to push to kiln, which is also the default here. The alias default is the one that's used when you don't specify anything else. This way push and pull with no arguments would use your preferred remote host, kiln.

Sadly you can't do a hg push * type command to push to all remote hosts at once, you have to specify each push destination one by one.

Danny Tuppeny

I'm not sure if you can edit the hgrc file on Bitbucket/Kiln. If you can, you may be able to make this automatic. If not, you could push to another local copy, which then pushes to both Bitbucket and Kiln using Hooks. See this answer by Ton (included below for convenience):

In your central server you create an changegroup hook.

So your central server would have the following hgrc:

[paths]
server2=http://server2
server3=http://server3
[hooks]
changegroup.server2 = hg push -f server2
changegroup.server3 = hg push -f server3

You can have multiple hooks for the same event, so that shouldn't be an issue. The advantage of the changegroup hook over the changeset hook is that it is run far less often.

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