neverpanic.de

Subversion Property Copy

| Comments

Although there are a couple of Subversion GUIs for Macs, I usually use the command line interface. 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:

single-line subversion property copy
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:

svn wrapper providing svn propcopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 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.

Comments