pre-revprop-change hook in TortoiseSVN

Posted on Jan 10, 2013

To edit a log of the committed revision in SVN, you need to unlock the pre-revprop-change hook. I found that the following two tips are very useful. In Windows, writing a batch script, pre-revprop-change.bat, in the hooks folder will do.

In order to use the svn propedit command on a revision properly (like svn:log which is the log message property), you do need a pre-revprop-change hook, because the default behaviour is to deny revision property changes. The easiest way to add a pre-revprop-change hook is to make a copy of the pre-revprop-change.tmpl file (which you’ll find in /repository-name/hooks in your svn directory), call it pre-revprop-change and make it executable (chmod a+x).

:: Set all parameters. Even though most are not used, in case you want to add
:: changes that allow, for example, editing of the author or addition of log messages.
set repository=%1
set revision=%2
set userName=%3
set propertyName=%4
set action=%5

:: Only allow the log message to be changed, but not author, etc.
if /I not "%propertyName%" == "svn:log" goto ERROR_PROPNAME

:: Only allow modification of a log message, not addition or deletion.
if /I not "%action%" == "M" goto ERROR_ACTION

:: Make sure that the new svn:log message is not empty.
set bIsEmpty=true
for /f "tokens=*" %%g in ('find /V ""') do (
set bIsEmpty=false
if "%bIsEmpty%" == "true" goto ERROR_EMPTY

goto :eof

echo Empty svn:log messages are not allowed. >&2

echo Only changes to svn:log messages are allowed. >&2

echo Only modifications to svn:log revision properties are allowed. >&2

exit /b 1