Migrating from Visual SourceSafe to Mercurial
This is part two in a series of blogs about migrating source code from one version control system (VCS) to another. Part one was about migrating code from Subversion to Mercurial, in case you missed it. This time we’re tackling something a little trickier: migrating from Visual SourceSafe (VSS) to Mercurial.
The Mercurial site has a page that describes two possible approaches, and for whatever it’s worth I found the second more direct and easier than the first. The only real down side is that you need Visual SourceSafe set up and working, which I no longer had. So here’s the high-level view of the procedure:
- Get VSS working at the command line with all the right data.
- Prepare the conversion environment with Perl and the necessary script.
- Perform the conversion and test the resulting repository.
Let’s go through these one at a time. First, in my case I couldn’t get the old VSS network setup to run under Windows 8.1 at all. Rather than fight that, I created a new virtual machine running the venerable Windows XP. I used VMware Workstation, but you can use any such tool. For example, Oracle’s VirtualBox is free, simple to use, and works nicely with Vagrant to spin up just such a box.
With VSS installed I had to tweak the environment to get it working at the command line. For example, I had to set the SS_HOME environment variable to the path for the VSS executables and add it to my PATH. I also had to create a new user via the VSS admin tool and set the SSUSER and SSPWD variables to the name and password I used. The key to step (1) is that you must have the VSS command line (SS.EXE) working properly in order for the conversion to work.
Moving on to (2), I downloaded ActiveState Perl and installed it in my 32-bit Windows XP VM. Once that was working, I downloaded the Vss2hg.pl script from the aforementioned Mercurial page and executed a quick perl vss2hg.pl --help command to verify that it could indeed run and review its arguments. With all that prelude out of the way, the conversion process itself was pretty easy via a single command:
perl vss2hg.pl --ssrepo="C:\Program Files\Microsoft Visual Studio\VSS" --sshome="C:\Program Files\Microsoft Visual Studio\VSS\win32" $/
The script requires only three arguments. The ssrepo argument provides the location of the VSS data files, the sshome argument specifies where to find the VSS binaries, and the final argument tells the script which project(s) to convert. In my case I had dozens of projects, so I just pointed it at the VSS root or “$/”in VSS parlance. The script has other options worth considering, so be sure to read the help.
And that was it for me: the conversion went to completion within a few hours and spit out a proper Mercurial repository in the folder from which I ran it. I didn’t have any problems, but I did come across a blog post offering some fixes along the way if you do. Good luck with your own migration!
Read part one of this series on Migrating from Subversion to Mercurial.