5 # The pre-lock hook is invoked before an exclusive lock is
6 # created. Subversion runs this hook by invoking a program
7 # (script, executable, binary, etc.) named 'pre-lock' (for which
8 # this file is a template), with the following ordered arguments:
10 # [1] REPOS-PATH (the path to this repository)
11 # [2] PATH (the path in the repository about to be locked)
12 # [3] USER (the user creating the lock)
14 # The default working directory for the invocation is undefined, so
15 # the program should set one explicitly if it cares.
17 # If the hook program exits with success, the lock is created; but
18 # if it exits with failure (non-zero), the lock action is aborted
19 # and STDERR is returned to the client.
21 # On a Unix system, the normal procedure is to have 'pre-lock'
22 # invoke other programs to do the real work, though it may do the
25 # Note that 'pre-lock' must be executable by the user(s) who will
26 # invoke it (typically the user httpd runs as), and that user must
27 # have filesystem-level permission to access the repository.
29 # On a Windows system, you should name the hook program
30 # 'pre-lock.bat' or 'pre-lock.exe',
31 # but the basic idea is the same.
33 # Here is an example hook script, for a Unix /bin/sh interpreter:
39 # If a lock exists and is owned by a different person, don't allow it
40 # to be stolen (e.g., with 'svn lock --force ...').
42 # (Maybe this script could send email to the lock owner?)
43 SVNLOOK
=/usr
/local
/bin
/svnlook
47 LOCK_OWNER
=`$SVNLOOK lock "$REPOS" "$PATH" | \
48 $GREP '^Owner: ' | $SED 's/Owner: //'`
50 # If we get no result from svnlook, there's no lock, allow the lock to
52 if [ "$LOCK_OWNER" = "" ]; then
56 # If the person locking matches the lock's owner, allow the lock to
58 if [ "$LOCK_OWNER" = "$USER" ]; then
62 # Otherwise, we've got an owner mismatch, so return failure:
63 echo "Error: $PATH already locked by ${LOCK_OWNER}." 1>&2