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?
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.
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 .
In Subversion, there are two types of properties:
On top of that, are three special revision properties associated with each revision that are rather important:
svn:log
: This is the commit messagesvn: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:
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"
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>
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With