Wednesday, February 18, 2009

Subversion Log Message Editing

One of the developers here on our staff at work needed to go back and modify a log message that he entered into a commit of Subversion, however, he wasn't able to do this.

According to the Subversion manual, there is a "hook" that you need to set to allow this. There are some default templates included in the Subversion repository upon creation, and you can just copy and rename those, however they are *nix scripts and don't work on Windows.

After some playing around I came up with a very basic Windows batch script that only allows modifications to the message log and nothing else (not the author, date, time, etc). The script follows if you'd like to use it:

@ECHO OFF SET REPOS="%1" SET REV="%2" SET USER="%3" SET PROPNAME="%4" SET ACTION="%5" REM Check to make sure only a modification is being made, no other actions allowed. IF NOT %ACTION%=="M" GOTO WRONG_ACTION REM Check to make sure only the message log is being modified, no other properties can be modified. IF NOT %PROPNAME%=="svn:log" GOTO WRONG_PROPERTY REM If the above conditions are true, exit gracefully. EXIT 0 :WRONG_ACTION ECHO "Sorry, only modifications of the message log are allowed" >&2 GOTO EXIT_ERROR_CODE :WRONG_PROPERTY ECHO "Sorry, your only allowed to modify log message!" >&2 GOTO EXIT_ERROR_CODE :EXIT_ERROR_CODE EXIT 1

No comments: