Subversion + Mercurial = True

In the team I am working in now, we are using Mercurial (ToroiseHg and VisualHg) as version control. This works great and we are quite happy with it. But there’s one little cloud on our sunny sky. We are interfacing with other teams and they are using Subversion. This means we have to switch between Mercurial and Subversion every now and then. Wouldn’t it be great if you could use Mercurial as a Subversion client? And guess what! You can!

There’s an extension to Mercurial called SubversionHg that lets you pull and push changes from/to a Subversion repository. We have used it for a while and it works fine, but there’s a few gotchas.

1. Download the source of the SubversionHg extension (
Unzip it and put it somewhere on your hard drive.
2. Start TortoiseHg Workbench go to the extensions settings (Select ‘File -> Settings’, then select the ‘Extensions’ category).
3. hgsubversion is not included in the list of extensions. You have to edit the settings file manually. Add this:

Note: The path is one level down in the source. If you unzipped the hgsubversion source (durin42-hgsubversion-0b07a0c574bc-zip) directly to C: then the path is C:durin42-hgsubversion-0b07ac574bchgsubversion
4. You will also need the ‘rebase’ extension, so put a check mark before it on the settings page.

You can clone a subversion repository using a path like this: svn+http://MySubversionServer/svn/MyProject
Don’t include ‘trunk’ in your path. Clone directly from the root of the Subversion repository!

Handling externals
If your subversion repository has externals defined (links to other subversion repositories). You will have to update this manually.
1. You should have a file named “.hgsvnexternals” in the root of your repository. The file should look like this:

The spacing in the file is important. There should be one space at the beginning of the line, before ‘MyExternalProject” and one space between the name and the url. If the spacing isn’t right it won’t work.
2. From the command line, ‘cd’ to the root of you repository and run “hg svn updateexternals”. All external files will now be downloaded.
3. Don’t check in the external files! Add them to the ignore list (.hgignore file)

Here’s more info on using subversionhg:

Leave a Reply

Close Menu