views:

5082

answers:

5

I'm looking for a tool to migrate a couple of SVN repos to Mercurial, with history, labels and so on.

I'm Using TortoiseHg (Windows x32), so ConvertExtensions are discarted.

There's some info on how to do this process on a Linux box (hgsvn) 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 HG?

+6  A: 

Mercurial has a built-in conversion extension for this.

Chad Birch
I know, It's the first thing i stumbled upon, but quoting: "Note that you can't do this with the Win32 Mercurial binaries -- there's no way to install the Subversion bindings into its built-in Python library"I'm using TortoiseHg ...
David Lay
Use a Linux live CD or a virtual machine?
rq
This is absolutely correct answer. I have done this using hg convert extension only (http://www.selenic.com/mercurial/wiki/WorkingWithSubversion#With_Convert_extension) and using the file protocol for SVN repository without pysvn extension:hg convert file:///X:/HOME/REPOS/mysvnrep newhgrep
van
+2  A: 
  1. startup svn server on localhost
  2. hg convert svn://localhost/your_repo
  3. done, because svn bindings needed only for file:// protocol
evilbloodydemon
Nopes, neither mercurial binaries for win32 or TortoiseHg comes with convert extensions, so "hg convert" is not even a valid command on win32.
David Lay
http://www.selenic.com/mercurial/wiki/ConvertExtensionConfigure your mercurial.ini to enable the extension by adding following lines: [extensions]hgext.convert=
evilbloodydemon
I tried using svn:// instead of file:// but it keeps asking for Python bindings
antispam
+1  A: 

This is in the TortoiseHg FAQ:

How can I convert a subversion repository to Mercurial?

You must install svn-win32-1.4.6 command line tools, then add them to your path. Then you must enable the convert extension. At this point, you should be able to use the 'hg convert' command to do the conversion. Please direct problems/questions about the convert extension to the Mercurial mailing list or #mercurial on irc.freenode.net.

So it is apparently possible -- I'm using Linux so I haven't tried myself.

Martin Geisler
+32  A: 

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.

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

  • XP or older - C:\Documents and Settings\USERNAME\Mercurial.ini
  • Vista or later - C:\Users\USERNAME\Mercurial.ini

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:

[extensions]
convert =

2) Search for the line that begins with

[extensions]

3) Below it you'll see a list of keywords, commented out with a semicolon (;) on each line

4) Find the line that says

;convert =

and delete the semicolon so it reads

convert =

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

hg convert file:///y:/yoursvnreponame

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.

Michael La Voie
Selecting the answer for this question was difficult. evilbloodydemon was right when he commented in his answer to edit the config to enable the convert extension, but this answer is more clear and precise
David Lay
I just wanted to mention that i tested this without the SVN command line client and it worked as well. You don't even need an SVN server functioning to do this, just access to the repository file path.
Michael La Voie
This worked well for me with Mercurial V1.4.3. A 1-year-old svn repository converted very quickly with the full history intact. Many thanks!
Jonathan Webb
Thanks, especially for the detailed instructions on which config file to edit. For reference, this also works when converting from an svn repo served over svn://
Zarigani
A: 

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:

python setup.py install

Which worked just fine on my Server 2003 box. I can now convert an SVN repo the correct way, by doing something like this:

python c:\python26\scripts\hg convert <remote repo>

The documentation for ConvertExtension on the Mercurial site isn't terribly clear, but it does say this:

There's no way to install the Subversion bindings into [Mercurial's] built-in Python library. So you'll need to use a Mercurial installed on top of a stand-alone Python

So now I just use the stand-alone version for converting, and TortoiseHg for actual VCS work.

Alex Fort