migrating from cvs to git

Sun, Aug 8, 2010

Recently I decided to move Guanxi from Sourceforge to GitHub as I like the social side of coding and being able to manage collaborations and committers better. I first had a go using git-cvsimport but it failed on the Engine, so I ended up taking the plunge and going with cvs2git. There’s a fair amount of setup required, so here are the steps I took to get Guanxi onto GitHub.

Local copy of CVSROOT

The first thing I needed was a local copy of the Guanxi CVS repository as cvs2git only works on local repos:

mkdir guanxi-cvs
cd guanxi-cvs
rsync -av rsync://guanxi.cvs.sourceforge.net/cvsroot/guanxi/* .

The next thing I needed was gdbm or this error appeared when I tried to run cvs2git:

ERROR: cvs2svn uses the anydbm package, which depends on lower level dbm
libraries.  Your system has dbm, with which cvs2svn is known to have
problems.  To use cvs2svn, you must install a Python dbm library other than
dumbdbm or dbm.  See http://python.org/doc/current/lib/module-anydbm.html
for more information.
Download gdbm from here.
./configure –prefix=/Users/alistair/apps/gdbm-1.8.3 –enable-shared
make install
cp *.a /Users/alistair/apps/gdbm-1.8.3/lib
cp .h /Users/alistair/apps/gdbm-1.8.3/include
cp .libs/.dylib /Users/alistair/apps/gdbm-1.8.3/lib
I needed those last copies as the install doesn’t work on OS X. Sometimes you can get it to work by changing BINOWN and BINGRP in Makefile but it didn’t this time.


Next up is installing Python while getting it to make use of gdbm. Download Python from here.

export CPPFLAGS=“-I/Users/alistair/apps/gdbm-1.8.3/include 
-L/Users/alistair/apps/gdbm-1.8.3/lib” export DYLD_LIBRARY_PATH=/Users/alistair/apps/gdbm-1.8.3/lib export LDFLAGS=“-L/Users/alistair/apps/gdbm-1.8.3/lib” ./configure –prefix=/Users/alistair/apps/python2.7 make make install
Once it’s finished building, you’ll see a bunch of libraries it couldn’t find but gdbm shouldn’t be one of them.


I got hold of cvs2git directly from the svn repo:

svn co –username=guest http://cvs2svn.tigris.org/svn/cvs2svn/trunk cvs2svn-trunk
cd cvs2svn-trunk
make man
I then made a copy of the options file:
cp cvs2git-example.options guanxi.options
and changed these variables:
ctx.tmpdir = r’output’

ctx.revision_collector = GitRevisionCollector( … ‘output/guanxi-sp-engine-blob.dat’,

ctx.output_option = GitOutputOption( … os.path.join(ctx.tmpdir, ‘guanxi-sp-engine-dump.dat’),

author_transforms={ … ‘alistairskye’ : (‘Alistair Young’, ‘alistair@codebrane.com’),

run_options.set_project( … r’/Users/alistair/dev/Guanxi/git/guanxi-cvs/Engine’,

and then ran it to convert the history for the Guanxi Service Provider Engine module:
./cvs2git –options=guanxi.options
Preparing the source code for migration

The first thing you realise is cvs2git only works on the history of the source. If you don’t init the new git repo with the original source you’ll end up with nothing but history files. So I started with the Engine module.

mkdir guanxi-sp-engine
cd guanxi-sp-engine
cp -r ~/dev/Guanxi/Engine/* .
Remove all the CVS directories and IDEA files
git init
git add .
Populating the new git history
cd guanxi-sp-engine
cat ../cvs2svn-trunk/output/guanxi-sp-engine-blob.dat /
     ../cvs2svn-trunk/output/guanxi-sp-engine-dump.dat | git fast-import
Although nothing has been committed by a “git commit”, doing “git status” at this point shouldn’t show anything needing to be committed as the entire history converted from CVS takes care of that.

All I had to do then was create a GitHub repository and push the Engine to it:

git remote add origin git@github.com:guanxi/guanxi-sp-engine.git
git push –all origin
I didn’t bother with “git push –tags” as they show as Downloads in the repo, which isn’t what I wanted. However, “git push –all origin” pushes all the branches, which is what I did want as they contain all the release code.

comments powered by Disqus