Configure a svn repository on SourceForge to allow changing a log message

I tend to make typos in the log messages to SubVersion commits and it is always embarrassing when I later come across these typos. Svn can be configured to allow changing log messages by adding a server hook, but that’s not the default.

The now defunct OSDN, which was based on an old version of the SourceForge software, offered an option to install the necessary server hook by just setting a check mark. Unfortunately SourceForge doesn’t seem to offer that convenience.

Fortunately, as the owner of a project, you have shell access to all your svn repositories (and a lot more), so you can install that hook yourself. You will need an ssh client (e.g. Putty) and follow some simple instructions.

First, configure Putty to connect to shell.sourceforge.net as described in the shell service support documentation. In particular note the additional entries you need to make in connection->ssh and connection->data. If you omit them, no shell will be started and the connection will be closed immediately.

Once you have opened a shell, change to the directory containing the svn repository e.g.

/home/svn/p/<projectname>/code

and further into the subdirectory hooks.

There you will find several files with a .tmpl (template) extension. These are put there by the standard svn server installation but the .tmpl extension prevents them from being active. The one we are interested in is pre-revprop-change.tmpl.

It contains lots of comments and the following code:

REPOS="$1"
REV="$2"
USER="$3"
PROPNAME="$4"
ACTION="$5"

if [ "$ACTION" = "M" -a "$PROPNAME" = "svn:log" ]; then exit 0; fi

echo "Changing revision properties other than svn:log is prohibited" >&2
exit 1

The line starting with "if" is the important one. It checks that the action is “M” (modify) and the property to be modified is "svn:log". If that is the case, it returns 0 which tells the svn server to allow changing that property. In all other cases it returns 1, prohibiting the change. You might want to restrict this functionality to a particular user (yourself) but by default it allows everybody to change the log message of any commit.

If you are fine with that, the the file already contains what we need, all that remains to be done is activating the hook.

In order to to that, rename the file to pre-revprop-change (without the extension) and make it executable if it isn’t already:

cd /home/svn/p/<projectname>/code/hooks
mv pre-revprop-change.tmpl pre-revprop-change
chmod +x pre-revprop-change

And that’s it. Now it is possible to change the log message of a commit from e.g. the TortoiseSVN log window.