How to edit log message already committed in Subversion?

304,934

Solution 1

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.

Solution 2

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.

Solution 3

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

Solution 4

svnadmin setlog /path/to/repository -r revision_number --bypass-hooks message_file.txt

Solution 5

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.

Share:
304,934
Paige Ruten
Author by

Paige Ruten

Updated on April 21, 2022

Comments

  • Paige Ruten
    Paige Ruten about 2 years

    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.

    I've seen How do I edit an incorrect commit message in Git?, but the solution to that question doesn't seem to be similar for Subversion (according to svn help commit).

    • oksayt
      oksayt almost 13 years
      I was going to upvote this question, but then I realized I already did 4 months ago :)
    • marty
      marty about 12 years
      If it is code, just make some comments and commit again with the appropriate comments. If you are ok with your comments reflecting the mistake, it is far less effort and much quicker. If not the solution by Kamil Kisiel is clearly the right way to do it.
    • jwa
      jwa about 10 years
      There is an excellent pre-revprop-change script that allows the committing user to modify their log for up to 3 hours after the commit. This is an excellent compromise between flexibility / accurate logs, and maintaining the fidelity of the repository: wandisco.com/svnforum/threads/…
    • mulllhausen
      mulllhausen about 6 years
      if you can't change the file but still want to add a new commit message then you can do svn propset dummyproperty 1 yourfile; svn commit yourfile -m yourmessage
  • Paige Ruten
    Paige Ruten over 15 years
    I'm using Google Code so I don't think I can do it this way, but thanks.
  • GreenMatt
    GreenMatt over 14 years
    As of Feb. 3, 2010, the URL is subversion.apache.org/faq.html#change-log-msg
  • Eligio Mariño
    Eligio Mariño about 14 years
    this worked for me as the propedit method failed with "Repository has not been enabled to accept revision propchanges". thanks!
  • Eligio Mariño
    Eligio Mariño about 14 years
    in Subclipse (Eclipse) it is "Set Commit Properties".
  • Rafa
    Rafa over 13 years
    +1 for giving the command directly :-) apache.org was down right now and I couldn't follow any given link...
  • Matt
    Matt almost 12 years
    It does require that the hook has been created - which requires admin rights. svn: Repository has not been enabled to accept revision propchanges; ask the administrator to create a pre-revprop-change hook
  • Carl Bussema
    Carl Bussema over 10 years
    For some reason, on my system (running Server 2012 and VisualSVN), in the last date check if /I not '%DATESTAMPDAY%'=='%DAY%' goto ERROR_MSGTOOOLD, I had to switch to double quotes around the two variables. (You would not believe how long that took to figure out.) Otherwise I would get things like "=='02' is unexpected at this time" (on the 2nd day of the month). My batch-fu is not strong enough to know why that happens, but in case anyone else runs into weird problems, it may help.
  • Apostle
    Apostle about 10 years
    Why you wrote in brackets "can not do chmod +x!"?
  • mmonem
    mmonem about 10 years
    I have created a small script that implements the same idea here blog.mmonem.com/enable-changing-svn-log
  • mmonem
    mmonem about 10 years
    Here is a script to enable the log: blog.mmonem.com/enable-changing-svn-log
  • Christian Severin
    Christian Severin almost 10 years
    At least in TortoiseSVN, trying to edit the commit properties for a commit in the commit log fails with the same error message as trying to directly edit the log message.
  • Christian Severin
    Christian Severin almost 10 years
    "DAV request failed; it's possible that the repository's pre-revprop-change hook either failed or is non-existent Repository has not been enabled to accept revision propchanges; ask the administrator to create a pre-revprop-change hook". But as I said: that's using TortoiseSVN (as a non-admin), not Eclipse. Maybe Eclipse hacks the SVN permissions to create that hook, I don't know.
  • mani_nz
    mani_nz almost 10 years
    Yea maybe. Try doing it in eclipse.
  • alemomo
    alemomo over 9 years
    @CarlBussema: Thanks for that tidbit. You just saved me a huge headache.
  • Peri Hartman
    Peri Hartman over 9 years
    This answer deserves more points! It is better because you don't have to setup the hook to use it.
  • albfan
    albfan almost 9 years
    Here is a basic implementation for svnadmin option svn-change-commit
  • Zitrax
    Zitrax over 8 years
    Also note that the script above uses american date format, "Expects date in the format: Thu 08/01/2013". So if you do not use that you need to modify that part, in my case the format was "mm.dd.yy", and without the week day.
  • NateJ
    NateJ over 8 years
    That's a cool variation on this nice answer: stackoverflow.com/questions/6155/…
  • segFaultCoder
    segFaultCoder over 7 years
    bump for this answer, worked for me without setting up the hook, also didn't change the revision "date/time" in the log, just the message, which was exactly what I was hoping for.
  • TheGabiRod
    TheGabiRod about 7 years
    Thanks this was an easier solution for me, +1. Is essential to have permissions.
  • Michael
    Michael almost 7 years
    Thanks! Still useful 6.5 years after the answer. :-)
  • Gerd
    Gerd over 6 years
    SVN_EDITOR, VISUAL or EDITOR need to be set before use svn propedit
  • GreenhouseVeg
    GreenhouseVeg over 6 years
    @ChristianSeverin, I get the same error message when using Eclipse. It surely comes from the Subversion server.
  • user_007
    user_007 about 4 years
    The propedit method more or less worked; however, I couldn't get the log change to reflect in the repo browser. I could only see the updated log in svn command line in Windows. I had to refresh the log cache as a final step: stackoverflow.com/questions/25750249/…
  • CursedGoat
    CursedGoat about 3 years
    Unfortunately, I needed this in 2021. Still accurate. thanks for sharing it.
  • Andrius R.
    Andrius R. about 2 years
    The link is dead. If someone has a copy of that script, please share.
  • Andrius R.
    Andrius R. about 2 years
    DATESTAMPDATE deconstruction no longer works. Need to add a space as a delimiter ... delims=- " , otherwise the last variable gets the whole remainder of svnlook date, which returns time and other stuff now (see SVN 1.7 docs or SVN nightly docs).