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

对着背影说爱祢 提交于 2019-11-30 11:05:28

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

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

#!/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

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
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!