Change SVN commit message retroactively?
Asked Answered
C

6

88

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.)

Causeuse answered 2/2, 2010 at 13:29 Comment(0)
F
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".

Fleur answered 2/2, 2010 at 13:35 Comment(4)
+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.Raffle
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?Ozmo
Are you asking me if you have a competent Subversion administrator? :)Fleur
@Ozmo 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.Algae
E
61

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.

End answered 2/2, 2010 at 13:36 Comment(3)
Thanks @kazark, I had to do svn propedit -r N --revprop svn:log to be able to change the message in my editor.Peirce
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 as mentioned above.Friable
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.exeBackrest
C
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.

Cytology answered 2/2, 2010 at 13:43 Comment(2)
+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.Causeuse
I added a link to an example command script: svn.haxx.se/users/archive-2006-03/0107.shtmlCytology
U
8

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

Ultramontanism answered 2/2, 2010 at 13:34 Comment(0)
S
4

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.

Samson answered 2/1, 2014 at 23:11 Comment(0)
K
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!

Knutson answered 30/8, 2013 at 9:46 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.