Preparing for Subversion to Git migration

GEOS is slowly moving to Git, so I decided to clear the Subversion specific settings, namely the svn:keywords. The procedure is quick and based on the commands I used to perform bulk svn:keywords property update.

First, svn:keywords property is removed:

find . -path '*/.svn' -prune -o -type f -print  | xargs svn propdel -q svn:keywords

Next, line consisting of $Id$ keyword is stripped from every plain text file using a tiny script coded in Python:


#! /usr/bin/env python
import fileinput
import re
import sys

def strip_line(filename, rx):
    sys.stderr.write(filename + '\n')
    for line in fileinput.input(filename, inplace=1):
        m = re.match(rx, line)
        if m is None:
            sys.stdout.write(line)
        else:
            sys.stderr.write(line)

if len(sys.argv) < 2:
    sys.exit("Missing filename")

pattern = '^.*\$Id.*$'
rx = re.compile(pattern, re.DOTALL)
strip_line(sys.argv[1], rx)

The script is executed for every file, excluding the working copy admin area in .svn:

for f in `find . -path '*/.svn' -prune -o -type f -print`; do ~/bin/strip_line_regex.py $f; done;

Voila!

Update: Torvalds answers Does GIT has vc keywords like CVS/Subversion?

Using Git with GDAL repository

I have mirrored Subversion trunk of GDAL repository on Gitorious – a free hosting for collaborating on distributed open source projects. It is available as svn-trunk repository of gdal project.

The main motivation is that it simplifies development of experiments in case one needs version control or complete disconnection from SVN trunk for some period. Thanks to git-svn, it is possible to push changes back to the trunk.

I outlined the process of maintaining GDAL trunk using Git in the Wiki article Using Git To Maintain GDAL Workflow.

The synchronization is not a time consuming process at all but even that I hope to make it automatic process in near future. First, I have to ship my little personal server to a remote data centre and I’m hoping to do it next week. Lucky bastard going to bask in the warm sun of Portugal :-)

mloskot.devjavu.com moved

Jeff Lindsay announced DevjaVu will be shutting down. This is bad news of the day for me, because I’ve been hosting on DevjaVu my personal workshop repository with miscellaneous prototypes and experiments at http://mloskot.devjavu.com/.

Due to Jeff’s decision, I’ve moved my repo to GitHub where is available as all-in-one workshop repository at http://github.com/mloskot/workshop/:

git clone git://github.com/mloskot/workshop.git

I?d like to send big thanks to Jeff and the DevjaVu team for two years of providing top-notch Subversion and Trac services. Good luck!

PostGIS SVN moved

Paul just announced that Subversion repository of PostGIS source code has moved to OSGeo server. The new URL of SVN is: http://svn.osgeo.org/postgis/.

Only base location of the repository has changed, so the cheapest way to switch existing working copy that points to old location of SVN is to switch & relocate:

mloskot@dog:~/dev/postgis/_svn/trunk$ svn switch --relocate \
   http://svn.refractions.net/postgis/trunk/  \

https://svn.osgeo.org/postgis/trunk

For the sake of security, I would recommend committers to use https scheme which is well supported on OSGeo server.

Juggling SVN keywords

When working in a team and maintaining large source code repositories, it’s easy to forget to set svn:keywords property for newly added file or update the property when adding new keywords to files.

The first solution that may come to once mind is to involve cron job or define post-commit hook. The former is easier to setup but may be unsafe if commits are allowed by authenticated users. The second option seems appealing as we can avoid authentication problems, but it’s generally not recommended to set properties from a hook. See warning in red frame in the Hook Scripts chapter of the SVN book.

After short discussion with folks on #gdal IRC channel, we have came to the conclusion that the easiest and safest option will be to periodically run a script fixing the svn:keywords where needed. Such script will be executed by team members on their local machines and against working copy of GDAL sources. This way we assure that the commit process is well authenticated and under human control :-)

So, here is the script – svnkeywords.sh (backed up here here):

$ ./svnkeywords $HOME/dev/gdal/_svn/trunk
Entering '/home/mloskot/dev/gdal/_svn/trunk'
Setting svn:keywords property........done.

It is quite generic and can run against any sources tree maintained by Subversion. The only requirement is Unix OS with toolset like /bin/sh, find and grep. Happy using!