One of the particularly nice things about working with a distributed revision control tool these days is that I can sidestep the choice of winning tool. Thanks to Scott Chacon and Augie Fackler’s excellent hg-git extension, I can use Mercurial and collaborate almost seamlessly with git users. This is exactly what I did when working with Johan on the new I/O manager subsystem in GHC 7, and the experience was generally very smooth.
The only mild annoyance has been that I’d prefer to also not be forced to choose a hosting winner: although bitbucket is pretty good, github is currently far slicker, and has a much larger community of potential collaborators.
I’ve hosted most of my code on bitbucket for quite a while. Until this morning, I had a somewhat awkward way to mirror code to github. I just automated the problem away.
My automation scheme is implemented as a Mercurial hook. Here’s how I’ve enabled it in my $HOME/.hgrc
file:
[hooks]
post-push = python:/home/bos/share/python/github_mirror.py:post_push
That github_mirror.py
hook is very simple. Every time I push, it checks to see if I'm pushing to a bitbucket repository, and if so checks my local repo's .hg/hgrc
file to see if I have a mirror on github. If I do, it pushes to github, too.
1 |
|
How do I tell Mercurial that I have a girhub mirror? In a repo's .hg/hgrc
file, I have something like this (taken from a real repo):
[paths]
default = http://bitbucket.org/bos/pcap
default-push = ssh://hg@bitbucket.org/bos/pcap
github = git+ssh://git@github.com/bos/pcap.git
The github_mirror.py
hook looks for that github
key in the paths
section of the file, and uses it if present.
Not sure I’m understanding the details, but is there something about setting up branches in hg that won’t automatically get mirrored to github here? If yes, suggested workarounds?
Nevermind; it’s a hg-git issue.
Bos, are you still using this setup? I see that your github repos are primarily the master repos.
Yes, I am.
BSD.Good question about cotenrnivg the tests – I didn’t think of that. Actually a few of these tests might already run under cinfony. For the moment though, I want to concentrate on sorting out OB’s SMILES parsing, but I’ll come back to you on this.