Stealing/Breaking Locks

531 views
Skip to first unread message

web...@tigris.org

unread,
Apr 27, 2009, 12:00:15 AM4/27/09
to us...@tortoisesvn.tigris.org
Hi All,
Our team is currently using tortoisesvn to work on the single project.But,Can anyone tell me how to disable the client users for locking/stealing of locks or may be limit this facility to the named administrator.
The documentation by collabnet suggests that it is possible through hook-scripts but not how to do that.I searched every where on net but didn't find the suitable solution.
Help me.
Thanks In Advance.

Ashwani Singh
Senior Software Engineer
EBC Publishing Pvt. Ltd

------------------------------------------------------
http://tortoisesvn.tigris.org/ds/viewMessage.do?dsForumId=4061&dsMessageId=1939547

To unsubscribe from this discussion, e-mail: [users-un...@tortoisesvn.tigris.org].

web...@tigris.org

unread,
Apr 27, 2009, 12:03:40 AM4/27/09
to us...@tortoisesvn.tigris.org
Hi All,
Our team is currently using tortoisesvn to work on the single project.But,Can anyone tell me how to disable the client users for locking/stealing of locks or may be limit this facility to the named administrator.
The documentation by collabnet suggests that it is possible through hook-scripts but not how to do that.I searched every where on net but didn't find the suitable solution.
Help me.
Thanks In Advance.

Ashwani Singh
Senior Software Engineer
EBC Publishing Pvt. Ltd

------------------------------------------------------
http://tortoisesvn.tigris.org/ds/viewMessage.do?dsForumId=4061&dsMessageId=1939571

Simon Large

unread,
Apr 27, 2009, 4:40:30 AM4/27/09
to us...@tortoisesvn.tigris.org
2009/4/27 <web...@tigris.org>:

> Hi All,
> Our team is currently using tortoisesvn to work on the single project.But,Can anyone tell me how to disable the client users for locking/stealing of locks or may be limit this facility to the named administrator.
> The documentation by collabnet suggests that it is possible through hook-scripts but not how to do that.I searched every where on net but didn't find the suitable solution.

Have a look at the pre-lock-hook template in the repository hooks directory.

Simon

--
: ___
: oo // \\ "De Chelonian Mobile"
: (_,\/ \_/ \ TortoiseSVN
: \ \_/_\_/> The coolest Interface to (Sub)Version Control
: /_/ \_\ http://tortoisesvn.net

------------------------------------------------------
http://tortoisesvn.tigris.org/ds/viewMessage.do?dsForumId=4061&dsMessageId=1942140

Ashwani Singh

unread,
Apr 28, 2009, 12:34:51 AM4/28/09
to us...@tortoisesvn.tigris.org
Hi simon,Thanks for ur suggestions.
I have already gone through tortoisesvn.net and had a deep look of pre-lock hook script template but not able to modify the content of pre-lock and the way to invoke this script.

For your information I am using

>TortoiseSVN 1.6.1
>AnkSVN for Integration in VS2008
>VisualSVN Server for repository browse

We have tried to edit this hook but it is giving error.

I hope you understand our problem.

Plz help me.
Thanks In Advance

------------------------------------------------------
http://tortoisesvn.tigris.org/ds/viewMessage.do?dsForumId=4061&dsMessageId=1958004

Simon Large

unread,
Apr 28, 2009, 5:51:57 AM4/28/09
to us...@tortoisesvn.tigris.org
2009/4/28 Ashwani Singh <kumar.w...@gmail.com>:

> Hi simon,Thanks for ur suggestions.
> I have already gone through tortoisesvn.net and had a deep look of pre-lock hook script template but not able to modify the content of pre-lock and the way to invoke this script.

It is a text file, so you can modify it using a text editor.

If you are running the server on Windows then you need to rewrite it
as a batch file (.bat) rather than a linux script, which is what the
template is. It can probably be very much simpler than the template,
but as we have no idea what you want to do we can't help you write it.

> For your information I am using
>
>>TortoiseSVN 1.6.1
>>AnkSVN for Integration in VS2008
>>VisualSVN Server for repository browse
>
> We have tried to edit this hook but it is giving error.

What error?

> I hope you understand our problem.

Sorry, I don't have a clue what your problem is because you haven't told us.

Simon

--
: ___
: oo // \\ "De Chelonian Mobile"
: (_,\/ \_/ \ TortoiseSVN
: \ \_/_\_/> The coolest Interface to (Sub)Version Control
: /_/ \_\ http://tortoisesvn.net

------------------------------------------------------
http://tortoisesvn.tigris.org/ds/viewMessage.do?dsForumId=4061&dsMessageId=1961573

Ashwani Singh

unread,
Apr 28, 2009, 6:55:36 AM4/28/09
to us...@tortoisesvn.tigris.org
Hi simon,
First of all thanks for your valuable suggestions.

The scenario is that we are working on the same project which resides on the VisualSVNServer through local copies on different user systems.

Suppose there are two users A and B.

A- This user has all the administrative rights.
B- Another user.

Now,If user A locks some page named 'abc.aspx' and working on it exclusively.Now suppose B wants to do work on the same page 'abc.aspx'..he can't work/commit because the page has been locked by the user A,but he can forcefully unlock by cheking through stealing chekbox.I dont want to allow this stealing facility to user B.What will i do to this pre-lock script to block the steallocking facility to user B except the administrator(means user A).

We hope you understand our problem.

Please help us to modify the pre-lock batch file for windows for the above mentioned problem.

------------------------------------------------------
http://tortoisesvn.tigris.org/ds/viewMessage.do?dsForumId=4061&dsMessageId=1962486

Simon Large

unread,
Apr 28, 2009, 7:48:37 AM4/28/09
to us...@tortoisesvn.tigris.org
2009/4/28 Ashwani Singh <kumar.w...@gmail.com>:
> Hi simon,
> First of all thanks for your valuable suggestions.
>
> The scenario is that we are working on the same project which resides on the VisualSVNServer through local copies on different user systems.
>
> Suppose there are two users A and B.
>
> A- This user has all the administrative rights.
> B- Another user.
>
> Now,If user A locks some page named 'abc.aspx' and working on it exclusively.Now suppose B wants to do work on the same page 'abc.aspx'..he can't work/commit  because the page has been locked by the user A,but he can forcefully unlock by cheking through stealing chekbox.I dont want to allow this stealing facility to user B.What will i do to this pre-lock script to block the steallocking facility to user B except the administrator(means user A).
>
> We hope you understand our problem.
>
> Please help us to modify the pre-lock batch file for windows for the above mentioned problem.

That is probably beyond the scope of a simple batch file as you need
something very close to what is in the linux template, which sends the
output of svnlook through grep and sed in order to find out who the
lock owner is. You could maybe use java, perl or python instead, or
maybe Windows scripting. But I am not an expert on any of those.

Simon

--
: ___
: oo // \\ "De Chelonian Mobile"
: (_,\/ \_/ \ TortoiseSVN
: \ \_/_\_/> The coolest Interface to (Sub)Version Control
: /_/ \_\ http://tortoisesvn.net

------------------------------------------------------
http://tortoisesvn.tigris.org/ds/viewMessage.do?dsForumId=4061&dsMessageId=1963070

web...@tigris.org

unread,
Apr 28, 2009, 8:09:33 AM4/28/09
to us...@tortoisesvn.tigris.org
Thanks Simon for ur replying.

1>But,I wanna to ask u whther it is possible or not?
2>Is there any other way to restrict users other than hook-scripts?
3>Can u please give us the hint so that we can atleast start?

Thanks In advance
Ashwani Singh

------------------------------------------------------
http://tortoisesvn.tigris.org/ds/viewMessage.do?dsForumId=4061&dsMessageId=1963146

Bob Archer

unread,
Apr 28, 2009, 9:28:49 AM4/28/09
to us...@tortoisesvn.tigris.org
> A- This user has all the administrative rights.
> B- Another user.
>
> Now,If user A locks some page named 'abc.aspx' and working on it
> exclusively.Now suppose B wants to do work on the same page
'abc.aspx'..he
> can't work/commit because the page has been locked by the user A,but
he
> can forcefully unlock by cheking through stealing chekbox.I dont want
to
> allow this stealing facility to user B.What will i do to this pre-lock
> script to block the steallocking facility to user B except the
> administrator(means user A).

This doesn't directly answer your question. But, I wonder, why are you
using locks on .aspx files? They are not binary files and
edit-update-commit work flow should not be a problem with these file
types.

BOb

------------------------------------------------------
http://tortoisesvn.tigris.org/ds/viewMessage.do?dsForumId=4061&dsMessageId=1963701

Simon Large

unread,
Apr 28, 2009, 9:59:53 AM4/28/09
to us...@tortoisesvn.tigris.org
2009/4/28 <web...@tigris.org>:

> Thanks Simon for ur replying.
>
> 1>But,I wanna to ask u whther it is possible or not?

Yes. Read the reply. I said it needs a very simple change to the
template hook script. The template only allows the lock owner to
unlock, which prevents stealing and breaking of locks. You need to
change that so that the admin user can also break locks.

> 2>Is there any other way to restrict users other than hook-scripts?

Not that I know of.

> 3>Can u please give us the hint so that we can atleast start?

How many more hints do you need? You want me to write the script for you?

You could try something like this. It is not the most efficient and it
is not tested, but it is a starting point.

pre-unlock.bat
--------------------------------------------------------------------------
@echo off
setlocal
set REPOS=%1
set PATH=%2
set USER=%3

:: Admin user can always unlock
if "%USER%" == "AdminUserName" exit 0

:: If no lock present return success
svnlook lock "%REPOS%" "%PATH%" | findstr /C:"^Owner:" > nul
if %errorlevel% gtr 0 exit 0

:: If lock is present but not owned by this user, deny unlock
svnlook lock "%REPOS%" "%PATH%" | findstr /C:"^Owner: %USER%" > nul
if %errorlevel% gtr 0 goto err

:: Own lock can be released OK.
exit 0

:err
echo Breaking locks is not allowed. 1>&2
exit 1
--------------------------------------------------------------------------

Simon

--
: ___
: oo // \\ "De Chelonian Mobile"
: (_,\/ \_/ \ TortoiseSVN
: \ \_/_\_/> The coolest Interface to (Sub)Version Control
: /_/ \_\ http://tortoisesvn.net

------------------------------------------------------
http://tortoisesvn.tigris.org/ds/viewMessage.do?dsForumId=4061&dsMessageId=1963863

web...@tigris.org

unread,
Apr 29, 2009, 12:26:41 AM4/29/09
to us...@tortoisesvn.tigris.org
Thanks Bob for replying,
I need to lock the .aspx files to give exclusive control to the page.Otherwise anyone can access and modify-commit that file.I dont want to allow this.

I tortoise SVN there is a facility of stealing the lock,I want to disable this facility to all the users except the administrator.

The documentation which i found on net describes that it is possible from pre-lock hook.But not telling how to edit this script/hook.

So can u please tell me hoe to edit this script so that it will solve our problem

Thanks
Ashwani Singh

------------------------------------------------------
http://tortoisesvn.tigris.org/ds/viewMessage.do?dsForumId=4061&dsMessageId=1974216

Simon Large

unread,
Apr 29, 2009, 4:19:49 AM4/29/09
to us...@tortoisesvn.tigris.org
2009/4/29 <web...@tigris.org>:

> Thanks Bob for replying,
> I need to lock the .aspx files to give exclusive control to the page.Otherwise anyone can access and modify-commit that file.I dont want to allow this.
>
> I tortoise SVN there is a facility of stealing the lock,I want to disable this facility to all the users except the administrator.
>
> The documentation which i found on net describes that it is possible from pre-lock hook.But not telling how to edit this script/hook.
>
> So can u please tell me hoe to edit this script so that it will solve our problem

Please take the trouble to read the replies you have already received.

Simon

--
: ___
: oo // \\ "De Chelonian Mobile"
: (_,\/ \_/ \ TortoiseSVN
: \ \_/_\_/> The coolest Interface to (Sub)Version Control
: /_/ \_\ http://tortoisesvn.net

------------------------------------------------------
http://tortoisesvn.tigris.org/ds/viewMessage.do?dsForumId=4061&dsMessageId=1977033

Bob Archer

unread,
Apr 29, 2009, 10:10:22 AM4/29/09
to us...@tortoisesvn.tigris.org
> Thanks Bob for replying,
> I need to lock the .aspx files to give exclusive control to the
> page.Otherwise anyone can access and modify-commit that file.I dont want
> to allow this.

Are you saying you want to limit the ability to access certain files to only 1 user at a time? Or, are you saying you don't think more than one person should be able to edit a form at the same time?

If the former then you can use access permissions or write pre-commit scripts to prevent people from committing certain files. If the latter then I suggest you review the svn docs and learn about WHY it is the best practice to use the Copy-Modify-Merge (http://svnbook.red-bean.com/nightly/en/svn-book.html#svn.basic.vsn-models.copy-merge) rather than Lock-Modify-Unlock (http://svnbook.red-bean.com/nightly/en/svn-book.html#svn.basic.vsn-models.lock-unlock) for text files. Do you have a reason to say "I don't want to allow this" other than it is different than some old SCC software you used to use?


> So can u please tell me hoe to edit this script so that it will solve our
> problem

I think Stefan basically already wrote the script for you in a previous message in this thread.

BOb

------------------------------------------------------
http://tortoisesvn.tigris.org/ds/viewMessage.do?dsForumId=4061&dsMessageId=1980420

web...@tigris.org

unread,
May 1, 2009, 12:33:30 AM5/1/09
to us...@tortoisesvn.tigris.org, Bob Archer
Thanks Bob,
Well,let me clear you that we want to restrict client users of tortoisesvn server to steal the lock.Besides that administrator should have all the rights to steal/break any of the client user lock.

I hope you are getting my point.
I have written the below script provided that 'ashwanisingh' is the name of the administrator:-


@ECHO OFF
:: Set all parameters. Even though most are not used, in case you want to add
:: changes that allow, for example, editing of the author or addition of log messages.
set repository=%1
set rev_path=%2
set userName=%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 ...').

::>> What the below line is doing..plz tell me.

FOR /F "delims=: tokens=1*" %%a IN ('svnlook lock "%repository%" "%rev_path%"') DO if %%a==Owner (set LOCK_OWNER=%%b)

:: If we get no result from svnlook, there's no lock, allow the lock to
:: happen:
if "%LOCK_OWNER%"=="" (
exit /b 0
)

:: If the person locking matches the lock's owner, allow the lock to
:: happen:

::>>Is the below userName variable contains something when user fires the command?


if "%LOCK_OWNER%" = "userName" (
exit /b 0
)
if "%LOCK_OWNER%" = "ashwanisingh" (
exit /b 0
)

::>>What the below lines are doing???


:: Otherwise, we've got an owner mismatch, so return failure:
echo "Error: %rev_path% already locked by %LOCK_OWNER%." >&2
exit /b 1


The above scipt partly solves our problem.That this script is blocking each and every user from stealing the lock
including the admin.

I have included my queries in the script.I am very grateful to you if you explain the above script line by line because i am not able to understand.

Thanks In Advance.

------------------------------------------------------
http://tortoisesvn.tigris.org/ds/viewMessage.do?dsForumId=4061&dsMessageId=2007389

Simon Large

unread,
May 1, 2009, 3:51:21 AM5/1/09
to us...@tortoisesvn.tigris.org, Bob Archer
2009/5/1 <web...@tigris.org>:

> Thanks Bob,
> Well,let me clear you that we want to restrict client users of tortoisesvn server to steal the lock.Besides that administrator should have all the rights to steal/break any of the client user lock.
>
> I hope you are getting my point.

I think we understand *what* you want to do, but we don't know *why*.
Subversion does not require locking because it can merge changes made
in different parts of a text file. But it is your call of course if
that's the way you prefer to work.

> I have written the below script provided that 'ashwanisingh' is the name of the administrator:-
>
>
> @ECHO OFF
> :: Set all parameters. Even though most are not used, in case you want to add
> :: changes that allow, for example, editing of the author or addition of log messages.
> set repository=%1
> set rev_path=%2
> set userName=%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 ...').
>
> ::>> What the below line is doing..plz tell me.
>
> FOR /F "delims=: tokens=1*" %%a IN ('svnlook lock "%repository%" "%rev_path%"') DO if %%a==Owner (set LOCK_OWNER=%%b)

Hang on. You wrote this script and you're asking us what it does???

Open a command console and type "FOR /?". It will give detailed help
on the Windows FOR command. It looks to me as if it is executing
svnlook and then parsing the output to look for the lock owner. My
approach would be to execute this batch file manually (run the command
yourself instead of waiting for it to happen automatically when an
unlock request happens) so you can insert some debug information.

Things to look for:
The process running the hooks on the server may not have the same PATH
as you do, so it may not even find svnlook without an absolute path.

Get the script to print out who it thinks the lock owner is so you can check it.

> :: If we get no result from svnlook, there's no lock, allow the lock to
> :: happen:
> if "%LOCK_OWNER%"=="" (
> exit /b 0
> )
>
> :: If the person locking matches the lock's owner, allow the lock to
> :: happen:
>
> ::>>Is the below userName variable contains something when user fires the command?

That is set in line 3 of the script. Subversion passes the username of
the person requesting the unlock.

> if "%LOCK_OWNER%" = "userName" (

That's not right. Should be "%userName%", to match the user who is
trying to steal the lock.

> exit /b 0
> )
> if "%LOCK_OWNER%" = "ashwanisingh" (
> exit /b 0
> )
>
> ::>>What the below lines are  doing???

Sending an error message back to the user. The >&2 forces the message
onto stderr instead of stdout, which is what subversion passes back to
the client.

> :: Otherwise, we've got an owner mismatch, so return failure:
> echo "Error: %rev_path% already locked by %LOCK_OWNER%." >&2
> exit /b 1
>
> The above scipt partly solves our  problem.That this script is blocking each and every user from stealing the lock
> including the admin.
>
> I have included my queries in the script.I am very grateful to you if you explain the above script line by line because i am not able to understand.

My guess is that the LOCK_OWNER is not being set correctly. The error
message returned when you try to steal a lock should tell you what it
was actually set to.

Simon

--
: ___
: oo // \\ "De Chelonian Mobile"
: (_,\/ \_/ \ TortoiseSVN
: \ \_/_\_/> The coolest Interface to (Sub)Version Control
: /_/ \_\ http://tortoisesvn.net

------------------------------------------------------
http://tortoisesvn.tigris.org/ds/viewMessage.do?dsForumId=4061&dsMessageId=2010639

Reply all
Reply to author
Forward
0 new messages