How to change VisualSVN log message after committing

2010-09-02


To make the VisualSVN server accept log message changes, a pre-revprop-change hook, that allows to change author or message, has to be installed for the repository. The default installation rejects changes to author and log message.

It is hard to find a sample hook script. but the following one is a solution but it need to put all script to a file and copy the file under /hooks folder in repository folder:

Just copy the following code to VisualSN Studio: Select database you want to set hook, then click right mouse button and get a "New Task" menu item -> select "Manage Hook", then select "Pre-revision proterty change hook" and edit , just copy the following code into OR save the following code as file "pre-revprop-change.bat" and throw it in the hooks directory.

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

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

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

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

:ERROR_EXIT
exit /b 1

And also there is a sample here. Maybe they are the same one.