Michal Čihař - Blog Archives for Coding

Migration to Subversion completed

Today last batch of Wammu and python-gammu has been converted to Subversion. It was almost painless, it only required lot of CPU time. All project pages should now link to Subversion repositories and snapshots. Also all projects now have publicly available statistics on http://www.ohloh.net and http://cia.vc.

Unfortunately for python-gammu and Wammu are statistics a bit messed up - for Wammu ohloh didn't find license header, which is in almost every file, in python-gammu, doc string comments are not counted as being comments, so without it project has obviously to low comments ratio.

Anyway I was quite impressed by code grow of Wammu in last half year, because I still thing I don't have enough time for Wammu. However if their stats are true, the code amount grows quite fast in last months.

Ancient ruins found

…and imported into subversion. Today I walked over some older stuff in my CVS repository, I decided to import them also to subversion.

The only major unpublished thing there is Wessie. It was supposed to be modular publishing system written in PHP. However I lost interest in improving this during time and it was used only on two real life projects - one is site about Alcatel phones, which is still alive, the other one was our semester project for software engineering, which is now dead.

Anyway maybe somebody will find the sources useful, so feel free to do with sources whatever GNU GPL permits :-).

New subversion repositories

I finally managed to migrate some things to Subversion from Bazaar. This does not yet include Gammu related things (Gammu, python-gammu and Wammu), because they are more tricky to migrate.

However all Debian packaging now can be handled using svn-buildpackage, which makes things a bit easier. Also smaller projects like Ukolovnik, polld and dictionary converter have been migrated.

You can see list of repositories at http://svn.cihar.com/, where is also link to web based browser.

Please note that repositories might change in future, because everything is not yet completely settled down.

Converting to Subversion

After more playing with Tailor, I managed to hack it enough to convert my Arch repositories to Subversion. Move from distributed to non distributed VCS migth look as step backwards, but I have pretty good reasons for this:

  • Subversion is widely used and there is big chance that potential contributor will know how to use it. This lowers barrier for contributing (especially when compared to current Arch/Bazaar).
  • Subversion sucks much less than CVS which is other well known VCS.
  • If I want to work distributed I can still use Bazaar-NG with foreign branch features.

The conversion is currently on the way and will probably need some time (about half of Gammu revisions have been converted so far).

VCS conversion troubles

It's probably time to give up. I tried to tweak tailor to make it able to convert my repositories to Subversion for several times, but without any success. It also fails to convert it to Bazaar-NG or Git. Those are list of all VCS I consider to use in future.

I'd prefer to switch to subversion, because it is widely used and most people will be willing to use it, but I have not find any way to convert current VCS data to it. Maybe I will start with empty repository and forget the history.

Optimise your code

Especiall if there is chance it will be used on something like OpenWRT. Yesterday I installed Munin on my OpenWRT router. Now I can see that sometimes statistics drop to zero, because it didn't manage to catch them.

I looked for most CPU hungry plugins and those are df_inode and processes. I rememeber that I already had to rewrite df_inode, because it was damn slow, so I only used that version (it should be also somewhere in their tracker, but I can not find it right now).

The processes plugin was also quite easy to optimise, compare old and new code:

 # time find /proc -type d | grep [0-9]$ | tr -d "/proc/" | grep ^[0-9]*$ | wc -l
 real    0m 0.77s
 user    0m 0.28s
 sys     0m 0.39s

 # time ls -d /proc/[1-9]* | wc -l
 real    0m 0.06s
 user    0m 0.04s
 sys     0m 0.00s

Buggy phones

I played a bit with Gammu and my phone (Sony-Ericsson K750i) yesterday, and I found yet another firmware bug. Enabling call line identification over cable (or any connection) makes phone hang when you receive call. Don't know why it is not able to look up number, when it already shows it on the display…

Converting locales data

I already announced that Gammu translations were converted to gettext. Reasons for conversion were written already some time ago. Now I'd like to write about some technical details on conversion.

First I thought the conversion will be simple. Just convert one text file format to other. Unfortunately there were lots of typos in old translations, which I had to fix, because gettext is much stricter about syntax. This itself would be also good reason to switch - old localisations had several types of errors, most frequently bad escaped quotes or messed format strings. This sometimes lead to Gammu crash, because it confuses printf like functions.

Another thing which was broken in old translation were duplicates of some strings. There were about 20 duplicate messages, which only added work to translators and were never used, because Gammu used first string which matched.

After I spot common mistakes, it was quite easy to write conversion script which would handle them. It is written in Python and uses its ConfigParser module to read old localisations. Using already done modules makes thinks a lot easier :-). After reading them, they are fixed to avoid syntax errors in gettext and written in gettext format to new file. All this in 123 lines of code (well, many of this are comments and string constants).

PS: You can download conversion script here, maybe it will be usable also for some other project.