Migrating from SVN to Git and Mercurial

There is a lot of answers here:
http://stackoverflow.com/questions/79165/how-to-migrate-svn-with-history-to-a-new-git-repository

I found rather useful this one.
A guy made a script according to proposed instructions: https://github.com/onepremise/SGMS

This script will convert projects stored in SVN with the following format:

/trunk
  /Project1
  /Project2
/branches
     /Project1
     /Project2
/tags
 /Project1
 /Project2
This scheme is also popular and supported as well:

/Project1
     /trunk
     /branches
     /tags
/Project2
     /trunk
     /branches
     /tags
Each project will get synchronized over by project name:

Ex: ./migration https://svnurl.com/basepath project1
If you wish to convert the full repo over, use the following syntax:

Ex: ./migration https://svnurl.com/basepath .



I tested on the second structure type and it works. The question is only about saving merge structure. It seems it was lost. :( Branches are ok, but merged revisions are not marked as merged. In other words every revision has single parent


Other solutions:

https://github.com/nirvdrum/svn2git
http://blog.tfnico.com/2011/12/git-svn-mirror-product-subgit.html
I haven't tested them.

Backup SVN

if the repository is not local. Dump whole repo:
svnrdump dump https://<your svn repo path>/ > dump.dump
then create a new local repo
svnadmin create newrepo
loading dump to local repo:
svnadmin load newrepo < dump.dump


I had a problem with loading (there was some internal error while loading more than 8000 revisions, so i try to make it another way).
You can dump in several files if you specify revisions ranges:

svnrdump dump  https://<your svn repo path>/ -r 0:1000 > dump0000-1000.dump
svnrdump dump  https://<your svn repo path>/ -r 1001:2000 --incremental > dump1001-2000-incremental.dump
svnrdump dump  https://<your svn repo path>/ -r 2001:3000 --incremental > dump2001-3000-incremental.dump

All dumps except the first are incremental

then create a new local repo
svnadmin create newrepo

then loading:
svnadmin load newrepo < dump0001-1000.dump
svnadmin load newrepo < dump1001-2000-incremental.dump
svnadmin load newrepo < dump2001-3000-incremental.dump

SVN server on localhost

I used VisualSVN Server to make local SVN server.
It seems Hg cannot load SVN repo from local file, but it can work with local server.
I added a new user, copied ready newrepo to a directory where VisualSVN Server stores repositories, assigned permissions to the repo and it worked.

Migrating to Hg

in russian: http://pdrobushevich.blogspot.ru/2010/10/hgsubversion.html

Finally I found solution for windows.
Install TortoiseHg.
Install  hgsubversion as a plugin to Tortoise. To do this, clone repository of hgsubversion somewhere. I cloned into D:/hgsvn:
hg.exe clone http://bitbucket.org/durin42/hgsubversion/ D:/hgsvn
In D:/hgsvn there is a folder hgsubversion. That is our target.
Then register plugin for TortoiseHg. Find mercurial.ini in home user directory and edit it. In section extensions add line hgsubversion = D:\hgsvn\hgsubversion
It must look like this:
[extensions]
hgsubversion = D:\hgsvn\hgsubversion
Now if you open  TortoiseHg->Global Settings->Extentions, you see the plugin was installed

Now you can just clone local SVN repository as Hg repo:
hg clone --verbose -- http://127.0.0.1/svn/<repo> D:\<repo>


Errors

I had following error while cloning using TortoiseHg:
EditingError: trying to open a deleted file
It seems the problem is gone when I close TortoiseHg and use command line
I spent a lot of time trying to understand the cause. It seems there is a bug of simultaneous work of gui and console.

No comments:

Post a Comment