How to move from remote SVN to Mercurial

I was working with SVN quite a long time and was happy about it. But number of active projects increased and some of them were needed to be supported even while travels. Since that time I moved to decentralised version control system and have control over my code-sources even when I’m travelling and without internet connection.

For code hosting I use for opencource projects and for private projects. supports both Git and Mercurial and allows 5 repo users for free. I prefer to work with Mercurial.

How to move a code repository from remote SVN server to Mercurial BitBucket?

First of all we need to SVN command line utilities called svnrdump and svnadmin.They are installed together with TortoiseSVN, if an option was checked in the installer.

If we access SVN through SSH then we need following:

  • PuTTY utilities pageant.exe and plink.exe must be in PATH
  • It is probably needed a system variable SVN_SSH with full path to plink.exe. I have for example SVN_SSH = “C://Program Files (x86)//PuTTY//plink.exe” Note double slashes here.
  • In the file ..\AppData\Roaming\Subversion\config in section [tunnels] we should uncomment line ssh = $SVN_SSH ssh -q
  • pageant.exe should be started with a private key
    "C:\Program Files (x86)\PuTTY\pageant.exe" c:\key_private.ppk

This is probably the most difficult part to make SVN work through SSH.

And now we are ready to move the repository.

1. Make a dump of the remote SVN repo to local file repo.dmp (this works with SVN from version 1.7)

2. Create a new local SVN repo and restore data from dump into it

3. Convert local SVN repo to Mercurial repo

If hg convert command does not work it means convert hg extension is not enabled. To enable it open Hg Workbench and go to File->Settings->Extensions check convert option there.

4. Transfer the created Mercurial repo to BitBucket
First create a new repo on BitBucket service. Then just push into it.

This is the longest operation and it is nice to have a fast Internet connection to complete it fast.
If we do this push in Hg Workbench there is a progress there on how many files are pushed.

5. Make the BitBucket repo default.
There is a file .hg/hgrc in repo folder, it has a [paths] section. Write the following line there:
default = ssh://

If plink complains about server’s host key is not cached in the registry:

Then we need to run plink directly in command line and confirm the key caching: