Try fast search NHibernate

30 May 2010

From SVN to Mercurial (in Windows7)

This is the resume a two successful  stories of conversion from an SVN repository to Mercurial.
Before start the conversion you will need the last available release of TortoiseSVN and TortoiseHg installed in your box.
Now you have the basic requirement you need to “activate” the Mercurial’s conversion plug-in. In your Win7 machine edit the file c:\Users\<YourUserName>\mercurial.ini and add the following two lines:

The conversion procedure

The real conversion is just one Mercurial’s command but if you have a repository hosted in the cloud, the best procedure, is to create a local read-only mirror of your SVN-repository.
In this example I will convert the ConfORM repository hosted in Google-code.

Create a new folder where put your local mirrors of your SVN repositories:
D:\>md svnmirrors
D:\>cd svnmirrors

To create the mirror:

D:\svnmirrors>svnadmin create ConfOrmMirror
D:\svnmirrors>cd ConfOrmMirror\hooks
D:\svnmirrors\ConfOrmMirror\hooks>echo. 2>pre-revprop-change.bat
D:\svnmirrors\ConfOrmMirror\hooks>cd ..\..
D:\svnmirrors>svnsync init --username fabiomaulo file:///d:/svnmirrors/ConfOrmMirror

Now the local mirror is ready to be synchronized with the remote repository (you can sync it any time you need).

D:\svnmirrors>svnsync sync file:///d:/svnmirrors/ConfOrmMirror

The synchronization will take a while depending on how long is the history of your repository (or the part was not synchronized).
After the synchronization I’m ready for the conversion.

D:\svnmirrors>md ConfOrmHg

Converting the full history, I want ‘convert’ even all committers names in order to use the Mercurial users convention. To achieve it, I will create a new file named authors.txt in the ConfOrmHg folder. In ConfOrm, so far, I’m the only one committer so:
Now I’m having everything needed to run the conversion directly from my local machine and if I forgot a user name or an e-mail or whatever may happen I don’t need to pay the pain of a conversion over the wire.

D:\svnmirrors\ConfOrmHg>hg convert file:///d:/svnmirrors/ConfOrmMirror ConfOrm -A authors.txt

Work done and now I’m ready to push to the remote Mercurial repository.

If you need to continue working on your SVN repository and only be ready to the conversion you can execute the synchronization any time you want and both, the sync and the conversion, will work only on differences from previous state.

1 comment:

  1. centralized version systems are getting very unattractive compared to de-centralized.

    Of course, svn shines very bright in the pool of ClearCase, CVS, SourceSafe