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:
  1. enable the MQ extension in .hgrc or Mercurial.ini
  2. check out the original Subversion repository
  3. in the checked-out copy, do
    hg init
  4. 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
  5. add all the files to Mercurial:
    hg ci -Am "Original svn checkout"
  6. initialize MQ:
    hg qinit -c
  7. if you have existing patches, you want to start applying them now. If they create new files, you'll need to "hg add" them
  8. 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 :)


Giulio Piancastelli said...
This comment has been removed by the author.
Giulio Piancastelli said...

Uh, nice, I didn't know about hg command abbreviations. You learn something every day.

Well, let us know how it goes. Somehow, I feel a certain amount of inertia to overcome in the whole process.

Giulio Piancastelli said...

Also, uhm, now that I learned a bit about MQ, I wonder why it is called "Queues" since, as far as I understood, it uses a data structure with stack semantics.