GoogleCode: Switching to Mercurial


After many years of committing the same crime of SVN I have come to realize the world is moving toward more robust and distributed version control systems like git, mercurial, bazaar or fossil. The primary reason for me to switch was the inability to turn around branches or merges quickly. Anyone who has used SVN will agree with me that its as painful to do branches and merges as it is define Cloud.

So I had to many choices in front of me I could either move to github, an extremely popular code hosting service around git or bitbucket which is also equally popular code hosting service around mercurial. But I saved either for later and chose to just migrate from SVN to mercurial on Google Code.

The migration is extremely simple that I thought for moment before I started writing this blog. Then I decided this will act as just as an a reference rather than anything more. You need to be the administrator of the project to carry out anything of this. I performed all these action from Fedora13 so there will be some distro specific differences.

I will my project “hgooglr”. The first thing to check on you Linux box is for the hg(Mercurial) version

$ hg --version
Mercurial Distributed SCM (version 1.7.5)
(see http://mercurial.selenic.com for more information)

Copyright (C) 2005-2010 Matt Mackall and othersThis is free software; see the source for copying conditions. There is NOwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

The version should be greater than the 1.2 this means that “hg convert” will be installed by default. But, convert is an hg extension so it needs to specified in the hg’s config file, on fedora this is located at /etc/mercurial/hgrc.d/hgk.rc. Edit this file to add the “hgext.convert=  ” under “[extensions]”, to look like this

[extensions]
# enable hgk extension ('hg help' shows 'view' as a command)
hgk=
hgext.convert=

The next thing to check will be see if the the python extension for subversion(SVN) is present or not. Most of the latest python installation will have them by default, otherwise it needs to be installed. Check it this way

$ python -c "import svn.core; print svn.core.SVN_VER_MINOR"
6

Need sure this is greater that 5. If these two checks pass we are now good to go.

The first thing I did was to go to my code hosting site http://hgooglr.googlecode.com and navigated to Administer > Source and changed the “Version Control System” to “Mercurial” and saved my changes. Then I switched back to console and create conversion directory and made it my working directory

$ mkdir conversion
$ cd conversion

There are two SVN paths that I needed to take on was the trunk and the other is the wiki. So create directories to represent them on my “conversion” directory.

$ mkdir trunk
$ mkdir wiki

Now I switched the trunk hosted at http://hgooglr.googlecode.com/svn to Mercurial by applying the following commands.

$ hg convert http://hgooglr.googlecode.com/svn trunk
$ cd trunk
$ hg push https://hgooglr.googlecode.com/hg
$ cd ..

Now I had my source code and all the history and tags up on Mercurial. Next was to move the wiki to mercurial as well for which the following commands were applied.

$ hg convert http://hgooglr.googlecode.com/svn/wiki wiki
$ cd wiki/
$ hg push https://wiki.hgooglr.googlecode.com/hg
$ cd ..

This migrated my entire repository from the SVN to mercurial. If you like to see what convert actually does please type the following

$ hg help convert

Pretty easy isn’t it.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s