List Info

Thread: Locking a file




Locking a file
user name
2008-04-17 10:12:47
Hi everyone!

I want to lock a file within my svn client so that only one
user (client) has write access. I'm a bit confused about the
API description tho:

lock( url_or_path,
      lock_comment,
      force=False )

Does this mean I can pass a URL (to a file on the repository
I guess) OR a path (to a file on the working copy)? But
where's the difference then?

If I give a path to a file in the working copy I can indeed
lock the file (and other clients, like Tortoise for windows
see this file correctly as locked). If I specifiy a URL to a
file in the repo I get the following error:

Code: 175002 Message: Lock request failed: 405 Method Not
Allowed (http://schbna6001)

Another thing is:
If I lock the file by giving a path and then another client
attempts to lock that file as well no exception is thrown
for that client!

Would be nice if someone could clarify the lock API for me


Greetings
Dominique



------------------------------------------------------------
---------
To unsubscribe, e-mail: users-unsubscribepysvn.tigris.org
For additional commands, e-mail: users-helppysvn.tigris.org


Re: Locking a file
user name
2008-04-19 07:21:08

On Apr 17, 2008, at 16:12, < Dominique.Holzwarthch.delarue.com">Dominique.Holzwarthch.delarue.com> < Dominique.Holzwarthch.delarue.com">Dominique.Holzwarthch.delarue.com> wrote:

Hi everyone!

I want to lock a file within my svn client so that only one user (client) has write access. I'm a bit confused about the API description tho:

lock( url_or_path,
      lock_comment,
      force=False )

Does this mean I can pass a URL (to a file on the repository I guess) OR a path (to a file on the working copy)? But where's the difference then?

You can lock a file directly in the repos using the URL without needed to checkout a working copy.


If I give a path to a file in the working copy I can indeed lock the file (and other clients, like Tortoise for windows see this file correctly as locked). If I specifiy a URL to a file in the repo I get the following error:

Code: 175002 Message: Lock request failed: 405 Method Not Allowed (http://schbna6001)


You need to ask on the SVN user list what this means. I can lock using PATH of URL to my HTTP server.
Of course your SVN server needs to be of a new enough version to support locking.

Another thing is:
If I lock the file by giving a path and then another client attempts to lock that file as well no exception is thrown for that client!


You need to process the notify messages that lock() generates. Here is an example:

import pysvn
import pprint

def notify( event ):
    print 'Notify:'
    pprint.pprint( event )

c=pysvn.Client()
c.callback_notify = notify


And here is its output:

: [1] barryemotion $ python2.5 l.py
Notify:
{'action': <wc_notify_action.failed_lock>,
 'content_state': <wc_notify_state.unknown>,
 'error': ("Path '/trunk/fred/Norway/testdok.txt' is already locked by user 'fred' in filesystem '/svn-library/barrys-test-lib/db'",
           [("Path '/trunk/fred/Norway/testdok.txt' is already locked by user 'fred' in filesystem '/svn-library/barrys-test-lib/db'",
             160035)]),
 'kind': <node_kind.unknown>,
 'mime_type': None,
 'path': 'testdok.txt',
 'prop_state': <wc_notify_state.unknown>,
 'revision': <Revision kind=number -1>}

See the code that WorkBench uses for a full example:

Would be nice if someone could clarify the lock API for me



Barry

[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )