26 February 2016

An open source project I used to play around with is, unfortunately, hosted on SourceForge. This is fine and all, as development ceased many years ago, but there is no mirror of the commit history. Even worse, the repo is still on CVS, which is best effort supported at this time. When SourceForge finally ceases, that history is lost.

Or so I thought…

Enter: cvs2git

cvs2git is a tool for migrating CVS repositories to git. It is provided as part of the cvs2svn project. It has some warts and a small learning curve, but for something I am only doing a handful of times (that I know of… do I have any more CVS projects lingering?) this seems fine to me.

Getting the code

So like I mentioned, this is SourceForge. First we need to get the working repository. We need the CVSROOT and all of the ,v files. Just having a checked out copy won’t cut it. Make sure you have rsync installed:

$ rsync -av rsync://PROJECTNAME.cvs.sourceforge.net/cvsroot/PROJECTNAME/\* cvs

Now you have a copy of the working repository.

Working with cvs2git

Acquire a copy of cvs2git-example.options (username is “guest”, no password) and place it in the cvs/ directory with the name cvs2git.options. The things that need to be modified are:

run_options.set_project(
    r'modulename',

And

author_transforms={
    'jrandom' : ('J. Random', [email protected]'),
    [...]

Now we transform the CVS repository:

$ cvs2git --blobfile=git-blob.dat --dumpfile=git-dump.dat PROJECTNAME

And let it crank away. It shouldn’t take very long, depending on the size of your repo.

Once that is done, we can context switch to git. Start by creating a bare repo:

$ mkdir PROJECTNAME.git
$ cd PROJECTNAME.git
$ git init

Then populate it

$ cat ../git-blob.dat ../git-dump.dat | git fast-import
$ git reset --hard

Now you have a git repo with commit history. Create a new repo on GitHub and push it up for the world to see.

Et voila

Here is my working example.