Growing Peace

Converting KMyMoney2 to git

November 6, 2008 · Leave a Comment

I wanted to start hacking on this wonderful financing software KMyMoney but really couldn’t do it because I just cannot use cvs. Either I am too lazy to learn cvs or I am perfectionist. In any case, the problem that I had was that I had some very small changes that were too small to send them as a patch to the mailing list, but still I just wanted to commit them to a local branch to have them out of my mind. With cvs I obviously can’t do it. I just couldn’t concentrate with all this clutter around (even if it was only two files). So I decided to create a git mirror of kmymoney.

This and this conversion guides were very helpful, but they did not contain all the steps that were necessary for me. I will give a quick step-by-step tutorial with all commands that I used. Note, however, that for non-sourceforge projects my description may be incomplete.

First make sure, you have the most recent versions of git and cvsps in your $PATH. At the time of writing, cvsps2.21b seems to be the most recent version. For cvsps, having a recent version is particularly important since there were/are some bugs that prevent/ed branches from converting correctly. I did not have problems with that, though.

You should create a local mirror of the cvs repository that you want to convert. This will reduce the load on the server and the running time dramatically. I used rsync for that, but someone reports that cvsup works, too.

$ mkdir kmymoney2.rsync
$ cd kmymoney2.rsync
$ rsync -r 'rsync://kmymoney2.cvs.sourceforge.net/cvsroot/kmymoney2/*' .

Now you should have a local copy of the cvsroot directory in kmymoney2.rsync/
Next you should create a file that maps the unix usernames used by cvs to realnames+email addresses used by git. If you want to commit your changes back to cvs, like here, you should not use this remapping, as adviced by the cvsimport man page. We call this file AUTHORS and put it in the current directory. Every line of the file should look like this:

username=FirstName LastName <email@example.com>

Then you can run git cvsimport to convert the cvs module ‘kmymoney2′ to a git repository.

$ git cvsimport -v -A $(pwd)/AUTHORS -C ../kmymoney2.cvsimport/ -d $(pwd) kmymoney2

The option -C specifies the path to the git repository to be created and -d the path to the CVSROOT directory. $(pwd) is just the current path. This command will take some time. Note that the AUTHORS file is automatically put into the .git directory as cvs-authors. Once you are finished, you can remove your rsync’d copy of the cvs repository if you like, and from now on keep your git mirror up-to-date by doing the following.

$ cd  ../kmymoney2.cvsimport/
$ git cvsimport -v -d :pserver:anonymous@kmymoney2.cvs.sourceforge.net:/cvsroot/kmymoney2 kmymoney2

This will fetch only incremental changes, just as if you did ‘cvs update’.

Note that you might want to call gc and repack to compress the git repository.

$ git gc --aggressive
$ git repack -a -d --depth=250 --window=250

The KMyMoney cvs repository had 142 MB, and my git mirror has only 29 MB.

Note that you shouldn’t ever work on the mirror directly. Clone the mirror instead.

I uploaded the converted git repository to github.com since it seems to have the friendliest user interface.

$ git remote add origin git@github.com:yllohy/kmymoney2.git
$ git push origin master

I even put up a cron job to do that hourly. You can usually do that as a non-root user, too.

$ crontab -e

Add the line

55 * * * * $(HOME)/devel/update-kmymoney2.sh &> /dev/null

The executable file $(HOME)/devel/update-kmymoney2.sh contains

#!/bin/sh
cd $HOME/devel/kmymoney2.cvsimport/
nice -n 19 git cvsimport -d :pserver:anonymous@kmymoney2.cvs.sourceforge.net:/cvsroot/kmymoney2 kmymoney2
nice -n 19 git push origin master

Thus, each hour at *:55, the changes are pulled from the cvs repository and written into the local git repository kmymoney2.cvsimport. Then these changes are pushed from the local git repository to the public repository at github. The command ‘nice’ executes git with the lowest possible process priority.

Have fun!

Categories: Uncategorized

0 responses so far ↓

  • There are no comments yet...Kick things off by filling out the form below.

Leave a Comment