87

I would like to re-write a big number of SVN commit messages to a different structure, e.g. prefix a category. From:

"foo" now accepts "bar" format for connection string.

I want

core - database - "foo" now accepts "bar" format for connection string.

Is there an easy way to do this that does not include dumping the whole repository using svndumpfilter?

I am working with TortoiseSVN on the client end, and VisualSVN on the server end. (VisualSVN is a wrapper around classic svn, which I can talk to through the command line as well.)

bahrep
  • 29,961
  • 12
  • 103
  • 150
Pekka
  • 442,112
  • 142
  • 972
  • 1,088

6 Answers6

100

Yes, commit messages can be changed. They are implemented as properties on revisions, similar to the regular file-properties.

In the TortoiseSVN Log window you can right click on a commit and select "Edit log message".

JesperE
  • 63,317
  • 21
  • 138
  • 197
  • +1 Thanks for this. I did some work involving some API changes that I wanted to commit separately to the rest, and I wrote the log message to reflect that... before accidentally committing the whole lot. I "fixed" it by committing a whitespace change with a log message that explained the rest! next time, I'll know what to do. – Ed Daniel Sep 17 '10 at 13:16
  • 1
    I gave this a +1 as well, but then it didn't work with a message "Repository has not been enabled to accept revision propchanges; ask the administrator to create a pre-revprop-change hook". Will the administrator automatically know what has to be done? – J.Merrill Oct 21 '11 at 15:33
  • 19
    Are you asking *me* if you have a competent Subversion administrator? :) – JesperE Oct 22 '11 at 12:51
  • @J.Merrill You have to browse to the `hooks` folder at the repository's location and rename the `pre-revprop-change.tmpl` to `pre-revprop-change.bat` for it to work. – sa_leinad Nov 01 '18 at 07:47
59

You can certainly change log messages retroactively, it's covered in the FAQ. I'm not sure how the command line interface for VisualSVN works, but for vanilla svn the command would be

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

If you want to do this for all revisions without dumping the repository and re-loading, you could script this command to work on a list of all revisions. It would take some time to do this way, depending on the size of your repository, but in principle there's no reason you can't do it, and it does not involve a dump and reload.

Also, vanilla SVN has a command svnlook which is sort of an administrative tool that works directly with the repository files. That tool doesn't understand URLs (you must have filesystem-level access to the repository), but is much faster. The syntax is a little different, but you can modify properties in the same way using that tool.

Adam Bellaire
  • 108,003
  • 19
  • 148
  • 163
  • 4
    Thanks @kazark, I had to do ```svn propedit -r N --revprop svn:log``` to be able to change the message in my editor. – tutuDajuju Jul 21 '13 at 12:14
  • 3
    Just to add a note: by default, that command will not work, because **changes to revision properties** is not allowed by default. In order to allow it, the svn administrator must create a hook called **"pre-revprop-change"**. This information is [in the FAQ](http://subversion.apache.org/faq.html#change-log-msg) as mentioned above. – Matthias Nov 18 '13 at 17:53
  • on Windows, you will need to set the environment variable "SVN_EDITOR", "VISUAL", or "EDITOR" before running the command. For example: `set SVN_EDITOR=notepad.exe` – Enwired Mar 03 '15 at 19:15
27

Yes, you can, but you need to enable it on the repository first.

In the repository, in the hooks directory, is a file called pre-revprop-change.tmpl. It's got a couple of pages of comments on what it does, and comes set up to only allow changes to the log properties. To enable it, rename the file to pre-revprop-change and make it executable (I'm assuming a POSIX-hosted subversion, if you're using Windows to host, you might find this message useful).

Once the repository allows it, you can use Tortoise to change the log message for a commit from the right-click menu on a commit, or you can use the command line.

Andrew Aylett
  • 39,182
  • 5
  • 68
  • 95
  • +1 Excellent information sir. It won't let me do it without a pre-revprop-change hook. I'll have to port the template bash script to windows, but that shouldn't be a problem. – Pekka Feb 02 '10 at 13:53
  • I added a link to an example command script: http://svn.haxx.se/users/archive-2006-03/0107.shtml – Andrew Aylett Feb 02 '10 at 14:46
7

Use svn propset on the svn:log property. Examples in the svn book.

Josh Lee
  • 171,072
  • 38
  • 269
  • 275
3

svn propedit -r N --revprop svn:log URL

URL above is optional if you're already in a working directory. An editor will then appear so that the message can be changed.

Raffi Khatchadourian
  • 3,042
  • 3
  • 31
  • 37
1

Just came accross this post with the exact problem, usingTortoise SVN for client and VisualSVN on a Windows server.

If you happen to have an "a DAV request failed" error message, give a look at Andrew Aylett's answer and go edit "pre-revprop-change.tmpl" in your repository hooks subdirectory.

Once this is done hitting "edit log message" in the contextual menu should finally work!

Community
  • 1
  • 1
Julien B.
  • 88
  • 6