2011-10-28
Performing Compatible Updates of Mozilla Central Git Forks
Earlier this year I posted about how I created my git mirror of the mozilla-central mercurial repository. I've been keeping a fork on github updated regularly since then that a number of people have started using.
Users of my mirror have wanted to be able to keep up to date with the mercurial mozilla-central repository themselves, or add updates from other branches of the Mozilla source. It takes a large amount of time to start a conversion from scratch but it's possible to start from the existing git mirror, perform the incremental updates from mercurial yourself, and still stay compatible with the incremental updates I push to my github mirror.
hg-git uses a git-mapfile
in the .hg
directory of the mercurial clone to keep track of the mapping between mercurial and git commits. By using the same git-mapfile
that I use for my mirror you can start your own incremental update from the latest data in the git-mapfile
instead of from the beginning. I keep an up-to-date git-mapfile
in git-mapfile.bz2. It's compressed with bzip2
as the uncompressed version is quite large.
The steps to start your own update process are:
- Clone the mercurial mozilla-central repository
- Clone my git mirror as a bare repository in
.hg/git
- Place the
git-mapfile
in.hg
- Do an
hg bookmark -f -r default master
to mark the commit to convert to - Perform
hg gexport
to update.hg/git
with recent mercurial commits
The .hg/git
directory should now be up-to-date with respect to the mercurial repository. And the additional git commits will have the same SHA id as any commits I push into my mirror when I perform my own update.
The steps to do an incremental update are the normal:
- Pull from the mercurial mozilla-central repository
- Run
hg bookmark -f -r default master
- Run
hg gexport
- Push or pull to/from
.hg/git
as needed
As a working example, the following shell commands on a Linux system should set up your own repository ready for incremental updating:
$ hg clone https://hg.mozilla.org/mozilla-central
$ cd mozilla-central/.hg
$ git clone --bare git://github.com/doublec/mozilla-central.git git
$ wget http://www.bluishcoder.co.nz/git-mapfile.bz2
$ bunzip2 git-mapfile.bz2
$ cd ..
$ hg bookmark -f -r default master
$ hg gexport
$ cd .hg/git
$ git push --all ~/some/other/repo.git
Incremental updates just repeat the last few commands above:
$ hg pull -u
$ hg bookmark -f -r default master
$ hg gexport
$ cd .hg/git
$ git push --all ~/some/other/repo.git
Note that I use hg gexport
and push from the .hg/git
repository using the git
command instead of doing an hg push
and relying on hg-git
to do the conversion and push. In my original article I did the latter. The hg-git push
method uses slower python based routines to do the push which can take a long time and large amounts of memory on big repositories like mozilla-central. By splitting this up into gexport
and using the native git
command I save a lot of time and memory.