Subversion Property Copy
16
.
February
2009
written by
Clemens Lang
at
Feb 16th 2009, 0:03
Although there is a couple of Subversion GUIs for Macs, I usually use the CLI. I manage all source code I write during my studies using Subversion and usually add revision number and date of last checkin to the file using the svn:keywords-Property. However, I always forget the set of keywords I usually add: Author Date Id Revision URL. Unfortunately, there is no way to copy a property from one file to another in the standard subversion binary. There is, however, a little shortcut:
svn propset $propertyName "`svn propget $propertyName $fromFileName`" $toFileName
Typing this monster isn’t any userfriendly at all, though – a little
.bashrc magic does the trick:
# add svn propcopy function svn() { case "$1" in pc|propcopy) propName=$2 fromFile=$3 shift 3 `which svn` propset $propName "`\`which svn\` propget $propName $fromFile`" $@ ;; *) `which svn` $@ ;; esac }
Update: Thanks to Raim for the wildcard support. Using subversion auto-props is an option for files, but unfortunately, auto-props don’t work on directories yet.
I usually use the same properties for specific file types, and it seems like you are doing the same. You can set up properties in the .subversion/config file which are evaluated automatically at ‘svn add’.
So adding something like this to your .subversion/config would be enough:
[miscellany]
...
enable-auto-props = yes
[auto-props]
*.java = svn:keywords=Author Date Id Revision URL
Oh, and for your original aid request, use the shift function which removes the first argument from the array:
# add svn propcopy
function svn() {
case “$1” in
pc|propcopy)
shift;
~/bin/svn-propcopy $@
;;
*)
`which svn` $@
;;
esac
}