SVN修改日志信息的hook文件

    如果你需要编辑已提交过的Commit日志信息,需要版本库配置pre-revprop-change的hook文件,否则提示修改失败:

 

DAV request failed; it's possible that the repository's pre-revprop-change hook either failed or is non-

existent
At least one property change failed; repository is unchanged
Error setting property 'log':
Repository has not been enabled to accept revision propchanges; ask the administrator to create a pre-revprop-
change hook

    在{版本库路径}/hooks下有一系列hook的模板,pre-revprop-change.tmpl默认提供Unix的sh脚本例子,文件主内容为:

 

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

    可以另存为pre-revprop-change.sh在Unix下使用(此项根据模板注释内容理解,未实际测试)。

 

    Window下的脚本内容如下:(使用方式:需要另存为pre-revprop-change.bat,然后放在hooks目录下即可使用SVN日志)

@ECHO OFF
:: 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

: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

    上述Window脚本在 Window7 + CollabNet SubversionEdge-1.3.0 下测试通过

    Window脚本来源:http://ayria.livejournal.com/33438.html


如果给你带来帮助,欢迎微信或支付宝扫一扫,赞一下。