WoWInterface SVN Blessed

[/] [hooks/] [pre-unlock.tmpl] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 Ailae-78500
#!/bin/sh
2 Ailae-78500
 
3 Ailae-78500
# PRE-UNLOCK HOOK
4 Ailae-78500
#
5 Ailae-78500
# The pre-unlock hook is invoked before an exclusive lock is
6 Ailae-78500
# destroyed.  Subversion runs this hook by invoking a program
7 Ailae-78500
# (script, executable, binary, etc.) named 'pre-unlock' (for which
8 Ailae-78500
# this file is a template), with the following ordered arguments:
9 Ailae-78500
#
10 Ailae-78500
#   [1] REPOS-PATH   (the path to this repository)
11 Ailae-78500
#   [2] PATH         (the path in the repository about to be unlocked)
12 Ailae-78500
#   [3] USER         (the user destroying the lock)
13 Ailae-78500
#   [4] TOKEN        (the lock token to be destroyed)
14 Ailae-78500
#   [5] BREAK-UNLOCK (1 if the user is breaking the lock, else 0)
15 Ailae-78500
#
16 Ailae-78500
# The default working directory for the invocation is undefined, so
17 Ailae-78500
# the program should set one explicitly if it cares.
18 Ailae-78500
#
19 Ailae-78500
# If the hook program exits with success, the lock is destroyed; but
20 Ailae-78500
# if it exits with failure (non-zero), the unlock action is aborted
21 Ailae-78500
# and STDERR is returned to the client.
22 Ailae-78500
 
23 Ailae-78500
# On a Unix system, the normal procedure is to have 'pre-unlock'
24 Ailae-78500
# invoke other programs to do the real work, though it may do the
25 Ailae-78500
# work itself too.
26 Ailae-78500
#
27 Ailae-78500
# Note that 'pre-unlock' must be executable by the user(s) who will
28 Ailae-78500
# invoke it (typically the user httpd runs as), and that user must
29 Ailae-78500
# have filesystem-level permission to access the repository.
30 Ailae-78500
#
31 Ailae-78500
# On a Windows system, you should name the hook program
32 Ailae-78500
# 'pre-unlock.bat' or 'pre-unlock.exe',
33 Ailae-78500
# but the basic idea is the same.
34 Ailae-78500
#
35 Ailae-78500
# Here is an example hook script, for a Unix /bin/sh interpreter:
36 Ailae-78500
 
37 Ailae-78500
REPOS="$1"
38 Ailae-78500
PATH="$2"
39 Ailae-78500
USER="$3"
40 Ailae-78500
 
41 Ailae-78500
# If a lock is owned by a different person, don't allow it be broken.
42 Ailae-78500
# (Maybe this script could send email to the lock owner?)
43 Ailae-78500
 
44 Ailae-78500
SVNLOOK=/usr/local/bin/svnlook
45 Ailae-78500
GREP=/bin/grep
46 Ailae-78500
SED=/bin/sed
47 Ailae-78500
 
48 Ailae-78500
LOCK_OWNER=`$SVNLOOK lock "$REPOS" "$PATH" | \
49 Ailae-78500
            $GREP '^Owner: ' | $SED 's/Owner: //'`
50 Ailae-78500
 
51 Ailae-78500
# If we get no result from svnlook, there's no lock, return success:
52 Ailae-78500
if [ "$LOCK_OWNER" = "" ]; then
53 Ailae-78500
  exit 0
54 Ailae-78500
fi
55 Ailae-78500
 
56 Ailae-78500
# If the person unlocking matches the lock's owner, return success:
57 Ailae-78500
if [ "$LOCK_OWNER" = "$USER" ]; then
58 Ailae-78500
  exit 0
59 Ailae-78500
fi
60 Ailae-78500
 
61 Ailae-78500
# Otherwise, we've got an owner mismatch, so return failure:
62 Ailae-78500
echo "Error: $PATH locked by ${LOCK_OWNER}." 1>&2
63 Ailae-78500
exit 1