No more changes on Subversion tags

Tagging is a standard pattern when using Subversion. Tags are immutable because this pattern tells us it is immutable, but Subversion has no builtin mechanism to prevent changes on tags. It is just like any other directory, so it can be changed. Fortunately Subversion has a pre-commit hook and this hook can used to make tags truly immutable.

The idea behind it is that there can be no changes inside the tree of the tag, but there can be any operation on the tag itself. This Windows script does the trick.

SET REPOSITORY=%1%
SET TRANSACTION=%2%

SET ERROR=1
SET SUCCESS=0

SET SVNLOOK="C:\Program Files\VisualSVN Server\bin\svnlook"

REM check if changes to a tag are committed
%SVNLOOK% changed %REPOSITORY% -t %TRANSACTION% | findstr /r /i "^.*/tags/[^/]*/..*"
IF %errorlevel% == 0 (GOTO CommitOnTagError)
GOTO End

:CommitOnTagError
ECHO. 1>&2
ECHO Error: 1>&2
ECHO    Changes to tags are not allowed. 1>&2
EXIT %ERROR%

:End
EXIT %SUCCESS%

Creating tags or branches for Subversion based on Hudson builds

Hudson has a builtin mechanism for tagging. Using this default mechanism helps a lot. However if you have multi-module jobs, you could still be stuck making the same changes in all those paths. Especially when you want to create branches instead of tags. Of course these manual changes are very errorprone. Especially when you are in a hurry. So it can be improved and that’s what this Ant script is about. Read more