How do you get the history of a file/folder property in SVN?
Asked Answered
C

5

26

What's the easiest way to determine when a property was set on a file or folder? Basically, I'm looking for an equivalent of "svn blame" that works on properties.

The log subcommand enables one to get the complete history of a file or folder, including when the properties have been modified. However, it doesn't distinguish between a property modification and other types of modification, which of course also means that it won't tell you anything about the history of a particular property.

The status command differentiates between properties and other types of modifications, but only works on the working copy.

Blame, itself, only supports files, not directories, and it works on the content, not the properties.

Ideas?

Checkoff answered 4/8, 2009 at 23:16 Comment(0)
R
10

The best I can think of is to write a little script or app that uses the svn propget command to dump the current property value to a text file, and then walks back through the revisions dumping the property to another text file and comparing the two. As soon as it detects a change, it prints out the revision number (actually the later revision number that made the change) along with the user who committed it.

Here's an example command to dump the svn:ignore property for the dictionary directory at revision 80:

svn propget -r 80 svn:ignore dictionary
Rodl answered 5/8, 2009 at 16:41 Comment(6)
I'm going to take the lack of better options as the answer that there is no ready way to do this. Ah well.Checkoff
The great thing about this is the person who committed that revision isn't necessarily the person who changed the property.Guadalajara
I don't understand, @anonfunc, how could somebody else change the property? I think the first revision that contains the new property value is always the revision that committed the change.Rodl
Say we have SVN at revision 80, last commit by Bob. I run svn propset svn:eol-style "LF" file. This modifies r80's properties, but it retains the same author, Bob. Then r81 gets committed by Alice. My property changes never got their own revision, and my name never enters the conversation.Guadalajara
Have you actually tried that, @anonfunc? In svn 1.5, it marks the file as modified in my working copy, and I would have to commit the change with a new revision. Are you confusing revision properties like svn:author and svn:date that are not versioned with file and directory properties like svn:eol-style that are versioned? There's a description of versioned and unversioned properties in the SVN manual.Rodl
Thank you for the correction. I didn't know about the distinction between versioned and unversioned properties and had used propset primarily on svn:log in the past.Guadalajara
C
11

One way to get a list of when properties for a given folder has changed is:

svn log -v . |grep "   M /trunk/datacenter$" -B2

Which gives the following output:

r963 | someuser | 2013-08-26 20:32:37 +0200 (Mon, 26 Aug 2013) | 4 lines
Changed paths:
   M /trunk/datacenter
--
r908 | someotheruser | 2013-08-15 12:15:03 +0200 (Thu, 15 Aug 2013) | 1 line
Changed paths:
   M /trunk/datacenter
--
r413 | someuser | 2013-04-26 09:02:08 +0200 (Fri, 26 Apr 2013) | 1 line
Changed paths:
   M /trunk/datacenter

Then you can look at each revision to see what changed:

$ svn diff -c963

at the bottom:

...

Property changes on: .
___________________________________________________________________
Modified: svn:ignore
## -22,3 +22,5 ##

 .idea
 .classpath
+
+dev-config.groovy

Cons:

  • No way to specify which property you're interested in
  • Tedious

Note: not sure -B2 is sufficient in all cases, as the line " M /trunk/datacenter" might not be the first line

Cana answered 26/8, 2013 at 19:6 Comment(1)
Best answer, upvoted this a long time ago. Hard to believe that Subversion provides no native way of filtering the log for this sort of detail.Carcinogen
R
10

The best I can think of is to write a little script or app that uses the svn propget command to dump the current property value to a text file, and then walks back through the revisions dumping the property to another text file and comparing the two. As soon as it detects a change, it prints out the revision number (actually the later revision number that made the change) along with the user who committed it.

Here's an example command to dump the svn:ignore property for the dictionary directory at revision 80:

svn propget -r 80 svn:ignore dictionary
Rodl answered 5/8, 2009 at 16:41 Comment(6)
I'm going to take the lack of better options as the answer that there is no ready way to do this. Ah well.Checkoff
The great thing about this is the person who committed that revision isn't necessarily the person who changed the property.Guadalajara
I don't understand, @anonfunc, how could somebody else change the property? I think the first revision that contains the new property value is always the revision that committed the change.Rodl
Say we have SVN at revision 80, last commit by Bob. I run svn propset svn:eol-style "LF" file. This modifies r80's properties, but it retains the same author, Bob. Then r81 gets committed by Alice. My property changes never got their own revision, and my name never enters the conversation.Guadalajara
Have you actually tried that, @anonfunc? In svn 1.5, it marks the file as modified in my working copy, and I would have to commit the change with a new revision. Are you confusing revision properties like svn:author and svn:date that are not versioned with file and directory properties like svn:eol-style that are versioned? There's a description of versioned and unversioned properties in the SVN manual.Rodl
Thank you for the correction. I didn't know about the distinction between versioned and unversioned properties and had used propset primarily on svn:log in the past.Guadalajara
Y
2
#!/bin/bash
# This is not a great solution, but it works for gathering the data

CURRENT_REVISION=95300
OLDEST_REVISION=93000
URL="file:///home/svn/repo/project/dir/target.c"
PROPERTY_NAME="svn:externals"

for i in `seq $OLDEST_REVISION $CURRENT_REVISION`
do
  svn -r$i propget "$PROPERTY_NAME" "$URL" | sed -e "s/^/$i\t/"
done
Yeoman answered 22/3, 2012 at 17:48 Comment(0)
P
0

My svn-extensions toolbox now has svn-prop-annotate and (as a specialization) svn-mergeinfo-annotate commands. They perform poorly (because they run svn log and svn diff for each potential change), and may still have some dependencies and perculiarities to my particular working style, but try them if you're desperate enough.

Here's some sample output:

$ svn-mergeinfo-annotate --author karkat -l 5
67645 ingo.karka    Merged /branches/1.50/foobar:r67488
67423 ingo.karka    Merged /branches/1.50/foobar:r67315,67331
67339 ingo.karka    Merged /branches/1.50/foobar:r67279
53320 ingo.karka    Merged /branches/foo-1.01:r53317
Phoenix answered 4/11, 2016 at 13:34 Comment(0)
U
0

Using the propget or proplist commands seem to be really, really slow.

For my purposes it was easy enough to do svn diff --properties-only on every revision and store it off. It stores enough information so that you can write some other scripts to do whatever comparing/blaming that is necessary without getting into the network shenanigans or whatever made propget/proplist so slow.

#!/bin/bash

# 7273 being the highest revision in my repository
for j in {1..7273}; do
    i=$((j-1))
    echo "$i:$j"
    svn diff --properties-only -r $i:$j https://... > propdiff.$j.txt
done
Unless answered 14/11, 2019 at 1:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.