source: branches/casa-prerelease/hooks/pre-lock.tmpl @ 2042

Last change on this file since 2042 was 2042, checked in by Kana Sugimoto, 13 years ago

created a place to store prerelease branch for CASA-ASAP

File size: 2.0 KB
Line 
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
35REPOS="$1"
36PATH="$2"
37USER="$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?)
43SVNLOOK=/usr/bin/svnlook
44GREP=/bin/grep
45SED=/bin/sed
46
47LOCK_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:
52if [ "$LOCK_OWNER" = "" ]; then
53  exit 0
54fi
55
56# If the person locking matches the lock's owner, allow the lock to
57# happen:
58if [ "$LOCK_OWNER" = "$USER" ]; then
59  exit 0
60fi
61
62# Otherwise, we've got an owner mismatch, so return failure:
63echo "Error: $PATH already locked by ${LOCK_OWNER}." 1>&2
64exit 1
Note: See TracBrowser for help on using the repository browser.