How to migrate/convert from SVN to Mercurial (hg)

2019-01-12 14:48发布

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?

9条回答
做自己的国王
2楼-- · 2019-01-12 15:14

Nobody still does not mention hgsubversion (Extension Wiki), which can do it without almost any headache (excluding rare cases and specific tree).

Just add extension, enable it and hg clone SVN_REPO to local mercurial repo

查看更多
贪生不怕死
3楼-- · 2019-01-12 15:14

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.

查看更多
叛逆
4楼-- · 2019-01-12 15:20

To convert an SVN Repo to an HG Repo AND copy it to a different server, you will need a few things.

  1. TortoiseHG installed. (Check to see what version is currently being used)
  2. Python Installed. (Check to see what version is currently being used)
  3. The Python Modules (you can find them http://pysvn.tigris.org/project_downloads.html)
  4. You will need to add the convert extension to Tortoise. Start the TortoiseHG Workbench from the Start menu. Select File -> Settings. Select Extensions from the list. Check the convert checkbox and click OK.

First the conversion…

  1. It is best to map the Folder that the current SVN Repo is in to the computer you are working on. (i.e. \\server\folder Do not map the SVN Repo folder itself. Map the folder just above it) Give the mapped drive a letter, like Y:\
  2. Open a command Prompt and type: CD /D Y:\
  3. At the Y:\ prompt type: hg convert y:/RepoName (use the name of the current Repo) Be careful of the forward and back slashes. The one in the command is a forward slash. Also, if the name has spaces, put the name in quotations. (i.e. Y:/"My Repo folder")
  4. Now it should be running and will create another folder alongside the old one. And an hg folder should be inside. IT WILL NOT BE INITIATED, AND DO NOT INITIATE!
  5. The conversion is complete.

Second the cloning…

  1. Open TortoiseHG Workbench. Go to File -> Clone Repository
  2. Source: Enter the full path of the converted repo.
  3. Destination: Enter the full path of where you want the repo cloned. It is not necessary to create a folder at the new destination as the cloning process will create it and initialize it.
  4. Add the permissions to the new cloned folder.
  5. You’re done!!!
查看更多
登录 后发表回答