7

I would like to add a comment to the subversion log or history for a given file, but there are no changes associated with that file.

Is there a way to add or inject a comment into the svn log without actually changing a file.

I am looking for a way to just tag a file in the log after some event occurs, for instance a code review.

I don't want to do a svn copy to create a whole new branch. I just want the comment associated with a single file at a point in time.

Any suggestions here?

Steve Stedman
  • 2,462
  • 3
  • 19
  • 21
  • http://stackoverflow.com/questions/304383/how-do-i-edit-a-log-message-that-i-already-committed-in-subversion - consider switching to git, if possible; it is more powerful (see git amend) – Stephan Apr 10 '12 at 16:23
  • To clarify, I am not looking for details on editing an existing log entry, I would like to add a new entry. – Steve Stedman Apr 10 '12 at 16:33
  • Additional: Switching away from SVN is not an option in this case. Switching to another source control product is out of the scope of this project. – Steve Stedman Apr 10 '12 at 16:34
  • 2
    @Stephan and how does it solve OP's issue? Git would have the same problems that OP is having. – David W. Apr 10 '12 at 18:19
  • the thing you can easily do via git amend is, to modify your last commit (or just the commit message) as a normal git-repo user... so you dont need to comment a commit, if you can edit the commit easily.. you dont have to use it - it was just a recommondation – Stephan Apr 11 '12 at 07:14

2 Answers2

6

In Subversion, there are two types of properties:

  • File Properties: These are properties associated with a file. They are revisioned as if they are part of the file itself.
  • Revision Properties: These are properties associated with individual revisions. There can only be one of each type of property per revision. They are not versioned, so changing a revision property will lose the historic information about the old information. As a safety precaution, you cannot change a revision property without first creating a pre-revprop-change hook that allows you to do it.

On top of that, are three special revision properties associated with each revision that are rather important:

  • svn:log: This is the commit message
  • svn:date: This is the date and time the commit was done.
  • svn:author: This is the user who did the commit.

So, the question is what are you trying to do. If you want to add a comment to a file, you can add a file property to that file. However, that's considered a file change, so you will have to do a checkout, svn pset and then a commit which creates a new revision on that file.

If you want to add a new comment to a particular revision in your repository, you don't have to create a new revision to do it. However, you'll have to create a pre-revprop-commit hook file that allows you to make these modifications. You have two ways of doing this:

  • Modify svn:log with your comment This is probably the easiest way. However, changes in the commit messages aren't logged, so you lose the original commit message in the process. The advantage is that this comment will display automatically with the svn:log command.

For example:

$ old_comment=$(svn pget -r 100 -revprop svn:log http://myhost/svn/repos)
$ new_comment="$old_comment
> ================ COMMENT ON REVISION ================
> This was a change needed for a particular customer"
$ svn pset -r 100 --revprop svn:log "$new_comment"
  • You can also create a new revision property that contains you comments. For example corp:comment (I use corp to signify special properties related to my company). You can display these comments in the svn log message, but only in xml format.

For example:

$ svn pset --revprop -r 100 foo:comment "This was a change needed for a particular customer" http://host/svn/repos

Now, when you do your log, you can see that comment:

$ svn log --with-revprop foo:comment --xml -r 100 http://host/svn/repos
<?xml version="1.0"?>
<log>
<logentry
   revision="100">
<revprops>
<property
   name="foo:comment">This was a change needed for a particular customer</property>
</revprops>
</logentry>
</log>
David W.
  • 98,713
  • 36
  • 205
  • 318
4

You can set/change a user-defined property on the file that should be committed - i.e. changing only some meta data without causing side-effects.

svn propset my:log reason filename
svn commit filename
nosid
  • 45,370
  • 13
  • 104
  • 134