SVNForum.org Forum Index FAQFAQ SearchSearch MemberlistMemberlist RegisterRegister Log inLog in

Download Subversion 1.6.12: Free Subversion TrainingWindows - Free Subversion TrainingCentOS 5 - Free Subversion TrainingRedhat Enterprise Linux 5 - Free Subversion TrainingUbuntu 9/10.04 - Free Subversion TrainingDebian Lenny (5)

Free Subversion Training: Free Subversion TrainingAll About Subversion Hook Scripts Free Subversion TrainingSubversion Locking Free Subversion TrainingAll About Checkouts
 
How can I detect the LOCK option --force in pre-lock?

 
Post new topic   Reply to topic    SVNForum.org Forum Index -> Scripts/Contributions
View previous topic :: View next topic  
Author Message
dundee



Joined: 18 Jul 2007
Posts: 5
Location: Nuernberg, Germany

PostPosted: Wed Jul 18, 2007 10:06 am    Post subject: How can I detect the LOCK option --force in pre-lock? Reply with quote

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
View user's profile Send private message
Argeman



Joined: 06 Jul 2007
Posts: 259
Location: Braunschweig, Germany

PostPosted: Wed Jul 18, 2007 10:11 am    Post subject: Reply with quote

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
View user's profile Send private message
Argeman



Joined: 06 Jul 2007
Posts: 259
Location: Braunschweig, Germany

PostPosted: Wed Jul 18, 2007 10:18 am    Post subject: Reply with quote

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
View user's profile Send private message
dundee



Joined: 18 Jul 2007
Posts: 5
Location: Nuernberg, Germany

PostPosted: Thu Jul 19, 2007 12:09 pm    Post subject: Reply with quote

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
View user's profile Send private message
J.C.P.



Joined: 06 Jan 2010
Posts: 1

PostPosted: Wed Jan 06, 2010 10:21 am    Post subject: Reply with quote

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
View user's profile Send private message MSN Messenger
andyl



Joined: 03 Nov 2005
Posts: 4790

PostPosted: Wed Jan 06, 2010 10:42 am    Post subject: Reply with quote

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 user's profile Send private message
View previous topic :: View next topic  
Post new topic   Reply to topic    SVNForum.org Forum Index -> Scripts/Contributions All times are GMT - 4 Hours
Page 1 of 1
Display posts from previous:   
Google
 
Web SVNForum.org