[PATCH] Add file locking for win32

John A Meinel john at arbash-meinel.com
Wed May 25 06:11:54 BST 2005


John A Meinel wrote:
...

> Anyway, I'm thinking to rewrite it so that it tries to obtain the lock
> with win32all, failing that it will use msvcrt, does that sound
> reasonable?
>
Because I thought it was reasonable, this is what I have done. See attached.

> Also, I noticed that Branch() does not automatically unlock the lockfile
> when it is done. Shouldn't that be done in the deconstructor?
>
I also added this, but it is only a couple lines around def
__del__(self): so it is easy to remove if desired.

> (And by the way, you weren't importing 'warning' from bzrlib.trace,
> though it was being used.)
>
Also fixed in the attached patch.

> John
> =:->
>
I went ahead and abstracted the locking so there is now a 'lock.py'
script which exports a lock() and unlock() function. lock takes a flags
argument of either LOCK_SH or LOCK_EX, and possible LOCK_NB.

Would you prefer it to be called mode and take 'r', 'w', and what would
you want for non-blocking locks? Deprecated posixfile used 'r|' to say
blocking, the default being non-blocking, or we could just forget
non-blocking exists, and just go with 'r' and 'w' (with 'w' being the
default).

John
=:->



-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 253 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20050525/052091d8/attachment.pgp 


More information about the bazaar mailing list