Aug 23, 2011

converting a CVS repository with branches to Mercurial ( hg )

I had to convert a old CVS repository with a lot of branches to Mercurial. 

The first attempt was to use the convert extension from Mercurial to do
a direct conversion from cvs to hg.

The conversion with
export CVSROOT
cvs co 

hg convert -A $HOME/authormap <cvsworkdir> <newHgRepo>
The conversion went through with a OutOfMemory during the run,
but hg convert can continue where it left the job.

But this new HG-Repository had wrong branch data inside.
After searching for a solution, I found out that the hints all said to
convert first to subversion and afterwards to mercurial.

Here is the home for repository conversion@Mercurial

I started by using cvs2hg which uses internally the cvs2svn code base.

After cloning the cvs2hg repo with
hg clone

and adjusting the config example I started to do the first run:

./cvs2hg  --options=./cvs2hg-example.options

My settings changed in the example config where
  • to set the decoders to latin1, 
  •  set the author_transforms dictionary
  • set ctx.output_option for the name of the new hg repository. 
  • set in run_otpions.set_project the path to the CVS repository to convert. 
The CVS-Repository was local on my machine instead of a network drive,
because hg convert also likes to have the repo locally.

The first run failed, because on my OpenIndiana there was a wrong dbm implementation in python for the module anydbm.

I downloaded the gdbm 1.8.3, compiled and installed in the default
path to /usr/local.
After this I had to download Python 2.7 and compile it locally.

First edit Module/Setup  in the python source tree:
gdbm gdbmmodule.c -I/usr/local/include -L/usr/local/lib -lgdbm
and some other modules inside the tree.
I had to set LD_LIBRARY_PATH to /usr/local/lib and /usr/sfw/lib for
gdbm and the gcc libs.

./configure --with-dbmliborder=gdbm --prefix <my installation dir>

After compiling and installing the new python,
a restart of the cvs2hg went through the conversion,l
and created a new HG repository.