[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: svnlook changed

From: Stefan Haller <haller_at_ableton.com>
Date: 2004-11-04 20:13:11 CET

BRUGGEMAN Jens (JBRG) <Jens.Bruggeman@seco-m.be> wrote:

> If you got a new file which is going to be added, there is no way you can
> use 'svnlook pg' or 'svn pg' at the server side because the file doesn't
> even exist there. He will never find the property . That's my main problem
> which needs to be solved :(

That's easy. Your pre-commit hook is called with two parameters, the
repository path and the transaction. You can get a file's properties
from that transaction, even for newly added files.

Something like the following, maybe. Warning: this is typed directly
into the mail message without trying if it's even syntactically correct.

#!/bin/sh

REPOS="$1"
TXN="$2"

: ${SVNLOOK:=/usr/local/bin/svnlook}
: ${SVNLOOK_SWITCH:=-t}

"$SVNLOOK" changed "$SVNLOOK_SWITCH" "$TXN" "$REPOS" | \
  while read line; do
    if echo -n "$line" | egrep -q '^[AU].*[^/]$'; then
      filepath="`echo -n "$line" | cut -c 5-`"

      eolstyle="`$SVNLOOK propget svn:eol-style "${SVNLOOK_SWITCH}" "$TXN" "$REPOS" "$filepath" 2>/dev/null`"

      if [ "$eolstyle" != native ]; then
        echo "File '$filepath' doesn't have" 1>&2
        echo "an svn:eol-style property of 'native'." 1>&2
        exit 1
      fi
  done || exit 1

exit 0

One hint for developing pre-commit hooks: it is a bit difficult to test
them, because you normally don't have a transaction around for testing.
What I do is make the -t switch of svnlook configurable, so I can call
my script to check an existing revisision instead like this:

$ SVNLOOK_SWITCH=-r myhook /var/svn/repos 17

-- 
Stefan Haller
Ableton
http://www.ableton.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org
Received on Thu Nov 4 20:14:13 2004

This is an archived mail posted to the Subversion Users mailing list.