Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add a comment to subversion without changing a file?

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?

like image 810
Steve Stedman Avatar asked Apr 10 '12 16:04

Steve Stedman


People also ask

Does svn allow editing changeset for specific commit in history?

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.

What does add do svn?

svn add adds an item (file or directory) to a local working copy. svn add is a local operation and does not contact server. No changes made to a repository when you run svn add . It simply schedules and item to be committed to a repository next time your run svn commit .


2 Answers

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>
like image 162
David W. Avatar answered Sep 22 '22 09:09

David W.


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
like image 44
nosid Avatar answered Sep 23 '22 09:09

nosid