5
# The pre-unlock hook is invoked before an exclusive lock is
6
# destroyed. Subversion runs this hook by invoking a program
7
# (script, executable, binary, etc.) named 'pre-unlock' (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 unlocked)
12
# [3] USER (the user destroying the lock)
13
# [4] TOKEN (the lock token to be destroyed)
14
# [5] BREAK-UNLOCK (1 if the user is breaking the lock, else 0)
16
# The default working directory for the invocation is undefined, so
17
# the program should set one explicitly if it cares.
19
# If the hook program exits with success, the lock is destroyed; but
20
# if it exits with failure (non-zero), the unlock action is aborted
21
# and STDERR is returned to the client.
23
# On a Unix system, the normal procedure is to have 'pre-unlock'
24
# invoke other programs to do the real work, though it may do the
27
# Note that 'pre-unlock' must be executable by the user(s) who will
28
# invoke it (typically the user httpd runs as), and that user must
29
# have filesystem-level permission to access the repository.
31
# On a Windows system, you should name the hook program
32
# 'pre-unlock.bat' or 'pre-unlock.exe',
33
# but the basic idea is the same.
35
# Here is an example hook script, for a Unix /bin/sh interpreter:
41
# If a lock is owned by a different person, don't allow it be broken.
42
# (Maybe this script could send email to the lock owner?)
44
SVNLOOK=/usr/bin/svnlook
48
LOCK_OWNER=`$SVNLOOK lock "$REPOS" "$PATH" | \
49
$GREP '^Owner: ' | $SED 's/Owner: //'`
51
# If we get no result from svnlook, there's no lock, return success:
52
if [ "$LOCK_OWNER" = "" ]; then
56
# If the person unlocking matches the lock's owner, return success:
57
if [ "$LOCK_OWNER" = "$USER" ]; then
61
# Otherwise, we've got an owner mismatch, so return failure:
62
echo "Error: $PATH locked by ${LOCK_OWNER}." 1>&2