svn - 如何编辑 Subversion 中已提交的日志消息?

标签 svn commit

有没有办法在 Subversion 中编辑某个版本的日志消息?我不小心在提交消息中写了错误的文件名,这可能会在以后造成困惑。

我见过 How do I edit an incorrect commit message in Git? ,但该问题的解决方案对于 Subversion 似乎并不相似(根据 svn help commit)。

最佳答案

本质上,您必须拥有存储库的管理员权限(直接或间接)才能执行此操作。您可以将存储库配置为允许所有用户执行此操作,也可以直接在服务器上修改日志消息。

参见this part Subversion FAQ的(强调我的):

Log messages are kept in the repository as properties attached to each revision. By default, the log message property (svn:log) cannot be edited once it is committed. That is because changes to revision properties (of which svn:log is one) cause the property's previous value to be permanently discarded, and Subversion tries to prevent you from doing this accidentally. However, there are a couple of ways to get Subversion to change a revision property.

The first way is for the repository administrator to enable revision property modifications. This is done by creating a hook called "pre-revprop-change" (see this section in the Subversion book for more details about how to do this). The "pre-revprop-change" hook has access to the old log message before it is changed, so it can preserve it in some way (for example, by sending an email). Once revision property modifications are enabled, you can change a revision's log message by passing the --revprop switch to svn propedit or svn propset, like either one of these:

$svn propedit -r N --revprop svn:log URL 
$svn propset -r N --revprop svn:log "new log message" URL 

where N is the revision number whose log message you wish to change, and URL is the location of the repository. If you run this command from within a working copy, you can leave off the URL.

The second way of changing a log message is to use svnadmin setlog. This must be done by referring to the repository's location on the filesystem. You cannot modify a remote repository using this command.

$ svnadmin setlog REPOS_PATH -r N FILE

where REPOS_PATH is the repository location, N is the revision number whose log message you wish to change, and FILE is a file containing the new log message. If the "pre-revprop-change" hook is not in place (or you want to bypass the hook script for some reason), you can also use the --bypass-hooks option. However, if you decide to use this option, be very careful. You may be bypassing such things as email notifications of the change, or backup systems that keep track of revision properties.

关于svn - 如何编辑 Subversion 中已提交的日志消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/304383/

相关文章:

git - Git 中的 merge 冲突与 Subversion 中的 merge 冲突相比如何?

save - Docker 提交不保存更改

linux - Bash 文本解析高尔夫

git - 有没有办法通过prepare-commit-msg独立地在 `git commit`上强制发送一条消息?

git - 您如何以不同的用户身份提交代码?

git - Git 小问题 - 更改默认编辑器

java - BAPI_TRANSACTION_COMMIT 是否提交自上次提交以来的更改

eclipse - 子剪辑 : Updating Change Sets for SVNStatusSubscriber (UPDATED - clock sync issue)

c# - 有谁知道一个好的 Subversion C# API?

svn - TortoiseSVN 和 subversion 的全局忽略