Migrating from Visual SourceSafe to Mercurial

If your organization use Microsoft SourceSafe as your version control tool, there are several reasons to stop doing that as pointed out in these blog posts:

Which version control system should you use instead? Well, there are a lot of tools to choose from, both free and commercial. In my opinion the best choice for most organizations is a Distributed version control system (DVCS). Popular tools are Git, Mercurial and Bazaar. These are all excellent tools, which one to choose is very much a matter of taste. In this post I will describe how I did a migration from SourceSafe to Mercurial for a client.

Migrating the repository

I haven’t found any reliable tool to migrate directly from SourceSafe to Mercurial, but there are many tools to migrate from SourceSafe to Subversion and it is possible to migrate from Subversion to Mercurial.

I tried a few tools for the SourceSafe –> Subversion conversion. I ended up using Vss2Svn, a tool with a simple command line interface. Vss2Svn creates a Subversion dump file, which can then be imported into Subversion. The following commands migrates the VSS repository into a new Subversion repository:

vss2svn –vssdir <path to your VSS database>   
svnadmin create C:\svn-repo    
svnadmin load C:\svn-repo< vss2svn-dumpfile.dat

To migrate your new Subversion repo to Mercurial you can use the convert extension to Mercurial. If you have installed TortoiseHg, you already have it. Just enable it from the Global Settings->Extensions page. Now start a local Subversion server with the command:

svnserve -r C:\svn-repo –d

If you would like to have each of your existing VSS project in a separate Mercurial repository, you will have to convert each one of them with a separate command, like so:

hg convert svn://localhost/YourProject YourProject

You will now have a new nice and warm home for your project!

One thing that was lost in translation was the labels from SourceSafe. I’m sure there is a way to keep them, but I didn’t have the time to investigate that.