I'm looking for a tool to migrate a couple of SVN repositories to Mercurial, with history, labels and so on.
I'm using TortoiseHg (Windows x32), so ConvertExtensions are discarded. There's some info on how to do this process on a Linux box (hgsvn), but I don't have a Linux machine available.
Can I use those Python scripts on Windows? If so, what do I need to do it? Or, what other tools can I use to do this process?
Basically, how can I convert an SVN project to Mercurial?
Using the
convert
extension of Mercurial:convert=
to the[extensions]
section of .hgrc like this:sudo apt-get install python-subversion
hg convert
commandhg convert -h
for helphg convert http://[svnserver]/[Project] --source-type svn [DestinationDir]
(see note 2)hg push https://[mercurialserver]/[Project]
note: you can even repeat the hg convert command to include new changes made in the svn repository after the previous convert.
note 2: When hg convert doesn't work using
http://
orsvn://
you could first checkout the Subversion repository (or update an existing one) and convert using the local checkout; example:hg convert [DirectoryOfLocalCheckout] --source-type svn [DestinationDir]
better late than never ...
Two answers for the price of one ...
If it is a public, open-source repo you could just use http://svn2github.com/add/ which took about half an hour to clone that repo to GitHib and then just pull that into Hg.
The advantage of using
hg convert
is that is can be resumed. Converting SVN to Hg can take days. If you stop this it will resume from where it left off.Below is a batch file I wrote because Codeplex SVNbridge rubbish. The repo in this example did take a couple of days to fetch the whole history (I'm in Australia so the latency may have been a factor). I'd like to think it gave a TFS server somewhere a good beating.
This batch file can be run at any time to pull updates from the SVN source if they happen to be the only ones left on earth actually still using SVN. I haven't tested it so see what happens if you do this so if I were you I'd abandon the original branch if you're going to edit the repo.
The
robocopy shamap
stuff is to maintain the SVN history if you clone the Hg repo, shamap is ephemeral - check the batch file & shamap in (I'd do that on a new branch).the batch...
I just had to tackle this problem myself. I have a windows XP machine with a separate windows server hosting VisualSVN Server.
I also have TortoiseHG installed as well as the CollabNet Subversion Command-Line Client.
<Enable Convert Extension w/ Tortoise Hg 2>
Many thanks to bgever for pointing out in the comments that with TortoiseHg 2.0, enabling the convert extension is easier than ever. As he says
</Enable Convert Extension w/ Tortoise Hg 2>
<Enable Convert Extension Manually>
To convert a repository from SVN to HG, I followed these steps:
1) Open C:\Program Files\TortoiseHg\Mercurial.ini
EDIT
FYI - Tortoise Hg has migrated this file to
That file will be mostly empty and you'll just list what you'd like to override there. If that's what you have, simple add these two lines to the very end of the file:
2) Search for the line that begins with
3) Below it you'll see a list of keywords, commented out with a semicolon (;) on each line
4) Find the line that says
and delete the semicolon so it reads
</Enable Convert Extension Manually>
5) Open the command prompt and navigate to the directory that you'd like the new hg folder created in (the process will create a new folder called yoursvnreponame-hg in the directory that the command prompt is open to).
6) Use this command
I found that the convert tool can have problems with networked repositories, so I had to map a drive to it, but this worked just fine for me.
Mercurial has a built-in conversion extension for this.
I just converted a remote SVN repo with HTTP auth to a Mercurial repo, and let me tell you, there's not a lot of documentation on how to do this. I had to download the Mercurial source and install it stand-alone, using the source package, that way the SVN bindings will work the right way.
I installed it like:
Which worked just fine on my Server 2003 box. I can now convert an SVN repo the correct way, by doing something like this:
The documentation for ConvertExtension on the Mercurial site isn't terribly clear, but it does say this:
So now I just use the stand-alone version for converting, and TortoiseHg for actual VCS work.