如何修改SVN中已提交的日志

直接在TortoiseSVN中修改过往日志,会提示:

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.

因为SVN库中的日志本身是没有进行版本管理的,为防止误操作导致原日志信息丢失,所以缺省禁止对其进行修改。如果要能在客户端进行修改,必须在repository的hook目录下新建一个pre-revprop-change.bat,内容如下:

if “%4” == “svn:log” exit 0
echo Property ‘%4’ cannot be changed >&2
exit 1

在属性修改前,该脚本会被执行,如返回0即表示同意修改。另外,注意该目录下本就有一个pre-revprop-change.tmpl,但那个是xNix的shell脚本,windows平台貌似不太好用。

然后在客户端就可以正常修改了,其后台应该是调用类似下面的命令:

svn propset -r N –revprop svn:log “new log message” URL

也可以在服务端通过运行下面的命令来做同样的事情,其中FILE是保存新日志信息的文件路径:

svnadmin setlog REPOS_PATH -r N FILE

如果不新建上面那个hook,就只能在服务端用svnadmin来修改,在上面的命令后加上–bypass-hooks就行。

This entry was posted in 软件开发 and tagged . Bookmark the permalink.

1 条 如何修改SVN中已提交的日志 的回复

  1. st说道:

    3Q,

    注意引号

    if “%4” == “svn:log” exit 0
    echo Property ‘%4′ cannot be changed >&2
    exit 1

发表评论

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 更改 )

Twitter picture

You are commenting using your Twitter account. Log Out / 更改 )

Facebook photo

You are commenting using your Facebook account. Log Out / 更改 )

Google+ photo

You are commenting using your Google+ account. Log Out / 更改 )

Connecting to %s