29 May 2009
Notes on Mercurial / MQ and Subversion
I am currently working on some patches for a project. The project uses Subversion for version control; I won't have commit rights, but I still want to track the original sources as well as my changes. Rather than configuring svn externals (which are really thought out for different usecases, typically libraries), I decided to try my hand at one of the newest Distributed Version Control Systems, which are built exactly for this sort of scenario.
Being a Python-whore, I obviously picked Mercurial. Here's a little memo with what I've done, mostly following the page on the Mercurial wiki dedicated to Subversion interop. Note that this may not be the optimal solution, it's a work-in-progress:
- enable the MQ extension in .hgrc or Mercurial.ini
- check out the original Subversion repository
- in the checked-out copy, do
hg init
- in the same place, create a file called .hgignore, listing the files we don't want to track; typically, this means the .svn/ directory and .hgignore itself
- add all the files to Mercurial:
hg ci -Am "Original svn checkout"
- initialize MQ:
hg qinit -c
- if you have existing patches, you want to start applying them now. If they create new files, you'll need to "hg add" them
- when you want to save state, use
hg qnew -f mynewpatch
This will create a patch called "mynewpatch" in the MQ stack, listing differences with the original version, and it will consider it as applied.
In this way, I can always resync the svn repository (using svn itself), commit the new "upstream" revision to the local hg repository, then reapply the patch queue. At least in theory :)
Labels: GeekDiary, mercurial, svn