How to edit log message already committed in Subversion?

前端 未结 10 1529
太阳男子
太阳男子 2020-11-27 23:54

Is there a way to edit the log message of a certain revision in Subversion? I accidentally wrote the wrong filename in my commit message which could be confusing later.

相关标签:
10条回答
  • 2020-11-28 00:38

    Here's a handy variation that I don't see mentioned in the faq. You can return the current message for editing by specifying a text editor.

    svn propedit svn:log --revprop -r N --editor-cmd vim
    
    0 讨论(0)
  • 2020-11-28 00:48

    On Windows, using Tortoise SVN client:

    1. right click in your project folder and choose "Show log"
    2. in the Log Messages window, right click on a revision and choose "Edit log message"

    If it doesn't work it might because of the way SVN on server is setup, read other responses here.

    0 讨论(0)
  • 2020-11-28 00:50

    When you run this command,

    svn propedit svn:log --revprop -r NNN 
    

    and just in case you see this message:

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

    Its because Subversion doesn’t allow you to modify log messages because they are unversioned and will be lost permanently.

    Unix-hosted SVN

    Go to the hooks directory on your Subversion server (replace ~/svn/reponame with the directory of your repository)

    cd ~/svn/reponame/hooks
    

    Remove the extension

    mv pre-revprop-change.tmpl pre-revprop-change
    

    Make it executable (cannot do chmod +x!)

    chmod 755 pre-revprop-change
    

    Source

    Windows-hosted SVN

    The template files in the hooks directory cannot be used as they are Unix-specific. You need to copy a Windows batch file pre-revprop-change.bat to the hooks directory, e.g. the one provided here.

    0 讨论(0)
  • 2020-11-28 00:51

    Essentially you have to have admin rights (directly or indirectly) to the repository to do this. You can either configure the repository to allow all users to do this, or you can modify the log message directly on the server.

    See this part of the Subversion FAQ (emphasis mine):

    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.

    0 讨论(0)
提交回复
热议问题