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:

  1. 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:
  1. # add svn propcopy
  2. function svn() {
  3. case "$1" in
  4. pc|propcopy)
  5. propName=$2
  6. fromFile=$3
  7. shift 3
  8. `which svn` propset $propName "`\`which svn\` propget $propName $fromFile`" $@
  9. ;;
  10. *)
  11. `which svn` $@
  12. ;;
  13. esac
  14. }

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.