| View previous topic :: View next topic |
| Author |
Message |
dundee
Joined: 18 Jul 2007 Posts: 5 Location: Nuernberg, Germany
|
Posted: Wed Jul 18, 2007 10:06 am Post subject: How can I detect the LOCK option --force in pre-lock? |
|
|
Hi,
we would like to suppress the possiblity of "steal lock" when locking a file.
Best place, I can imagine to implement, is the pre-lock hook script.
But how can I retrieve the --force information there?
TIA
Ciao
Olaf |
|
| Back to top |
|
Argeman
Joined: 06 Jul 2007 Posts: 259 Location: Braunschweig, Germany
|
Posted: Wed Jul 18, 2007 10:11 am Post subject: |
|
|
Hi!
Taken from the sample hook-script "pre-lock"
#!/bin/sh
...
REPOS="$1"
PATH="$2"
USER="$3"
# If a lock exists and is owned by a different person, don't allow it
# to be stolen (e.g., with 'svn lock --force ...').
# (Maybe this script could send email to the lock owner?)
SVNLOOK=/usr/local/bin/svnlook
GREP=/bin/grep
SED=/bin/sed
LOCK_OWNER=`$SVNLOOK lock "$REPOS" "$PATH" | \
$GREP '^Owner: ' | $SED 's/Owner: //'`
# If we get no result from svnlook, there's no lock, allow the lock to
# happen:
if [ "$LOCK_OWNER" = "" ]; then
exit 0
fi
# If the person locking matches the lock's owner, allow the lock to
# happen:
if [ "$LOCK_OWNER" = "$USER" ]; then
exit 0
fi
# Otherwise, we've got an owner mismatch, so return failure:
echo "Error: $PATH already locked by ${LOCK_OWNER}." 1>&2
exit 1 |
|
| Back to top |
|
Argeman
Joined: 06 Jul 2007 Posts: 259 Location: Braunschweig, Germany
|
Posted: Wed Jul 18, 2007 10:18 am Post subject: |
|
|
OK, the color wasnt that geat idea...
I forgot to mind you that unlocking could also be tried by someone who is not the owner of the lock. The pre-unlock template provides the same functionality.... |
|
| Back to top |
|
dundee
Joined: 18 Jul 2007 Posts: 5 Location: Nuernberg, Germany
|
Posted: Thu Jul 19, 2007 12:09 pm Post subject: |
|
|
Hello Argeman,
yes, you're right. There is no need to get the --force option from the command line.
Thanks for the info.
Ciao
Olaf |
|
| Back to top |
|
J.C.P.
Joined: 06 Jan 2010 Posts: 1
|
Posted: Wed Jan 06, 2010 10:21 am Post subject: |
|
|
| First of all, thanks for this script!! Was exactly what I was looking for!! Now, I would like to know if there is any possibility to send an email to the lock's owner to advice that someone else try to lock a file. |
|
| Back to top |
|
andyl
Joined: 03 Nov 2005 Posts: 4790
|
Posted: Wed Jan 06, 2010 10:42 am Post subject: |
|
|
| J.C.P. wrote: | | First of all, thanks for this script!! Was exactly what I was looking for!! Now, I would like to know if there is any possibility to send an email to the lock's owner to advice that someone else try to lock a file. | Hook scripts can do almost anything you want. |
|
| Back to top |
|
|
View previous topic :: View next topic |