Subversion Repositories FlightCtrl

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
948 dokunautic 1
#!/bin/sh
2
 
3
# PRE-LOCK HOOK
4
#
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:
9
#
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)
13
#
14
# The default working directory for the invocation is undefined, so
15
# the program should set one explicitly if it cares.
16
#
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.
20
 
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
23
# work itself too.
24
#
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.
28
#
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.
32
#
33
# Here is an example hook script, for a Unix /bin/sh interpreter:
34
 
35
REPOS="$1"
36
PATH="$2"
37
USER="$3"
38
 
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 ...').
41
 
42
# (Maybe this script could send email to the lock owner?)
43
SVNLOOK=/usr/local/bin/svnlook
44
GREP=/bin/grep
45
SED=/bin/sed
46
 
47
LOCK_OWNER=`$SVNLOOK lock "$REPOS" "$PATH" | \
48
            $GREP '^Owner: ' | $SED 's/Owner: //'`
49
 
50
# If we get no result from svnlook, there's no lock, allow the lock to
51
# happen:
52
if [ "$LOCK_OWNER" = "" ]; then
53
  exit 0
54
fi
55
 
56
# If the person locking matches the lock's owner, allow the lock to
57
# happen:
58
if [ "$LOCK_OWNER" = "$USER" ]; then
59
  exit 0
60
fi
61
 
62
# Otherwise, we've got an owner mismatch, so return failure:
63
echo "Error: $PATH already locked by ${LOCK_OWNER}." 1>&2
64
exit 1