Simple HG One-Way Mirroring

I recently contributed some code to a bitbucket hosted repository and registered on that platform because of that. From what I’ve seen so far bitbucket looks like a really nice place to host mercurial repositories and I’ve decided to mirror the important pocoo repositories there.

Turns out, that is really easy :) You need to generate a ssh key for the hg user on the server and add that to your ssh keys on bitbucket. Then create the repository there and add the following lines to the .hg/hgrc of the repository on the main server:

[paths]
bitbucket = ssh://hg@bitbucket.org/USERNAME/REPOSITORY

[hooks]
changegroup.bitbucket = hg push bitbucket

That’s all. Now every time you push something to the repostitory on the server that is forwarded to bitbucket too. As long as you don’t check in on bitbucket now the two repositories should be in sync.

More about bitbucket and why I like it a lot, in a separate blog post ;-)

Update: as suggested by crast it’s a way better idea to use changegroup rather than incoming. I edited the post accordingly. incoming would execute the hook for each changeset pushed.

2 Responses to “Simple HG One-Way Mirroring”

  1. Hey, cool trick, thanks for sharing! Do you mind if I include this post in future write-ups on bitbucket coverage?

    Comment by Jesper Noehr — Sunday, September 14th, 2008 @ 1:30 pm
  2. @Jesper: Sure, go ahead :)

    Comment by Armin Ronacher — Sunday, September 14th, 2008 @ 3:18 pm

Leave a Reply

cogitations driven by wordpress