Saturday, 15 August 2009

Converting Subversion to Mercurial (svn to hg) on Windows

If you’re jumping on the DCVS bandwagon and abandoning Subversion, Mercurial seems to be the way to go on Windows thanks to TortoiseHg and the fact that the Mercurial commands feel familiar if you’re used to Subversion.

It is possible to do a full history conversion from a Subversion repository to a Mercurial repository using Mercurial’s Convert extension. This doesn’t work out of the box on Windows so I did it using Cygwin.

Steps
Download Cygwin and select the mercurial and subversion-python packages from the Devel section during install. Selecting these will also select the other packages you need automatically.

Next create a text file named .hgrc in your C:\cygwin\home\Username folder containing the following:
[extensions]
hgext.convert=
Now open up your Cygwin bash shell and you might* be able to run a conversion e.g.
hg convert http://fluent-nhibernate.googlecode.com/svn/trunk/
See http://mercurial.selenic.com/wiki/ConvertExtension for more info and command options.

* If you get a *** fatal error *** about remapping addresses you will need to rebase your dlls. To do this quit the Cygwin shell, open a windows command prompt, CD to C:\cygwin\bin and run ash rebaseall. The hg convert should now work.