[RFC] Implement bzrlib.lock with CreateFile rather than LockFileEx on win32

Martin (gzlist) gzlist at googlemail.com
Wed Jun 10 12:13:56 BST 2009


Having had cause to look at the workings of bzrlib.lock the other day,
it seems that the desired semantics would be better implemented on
windows with a lock at file creation, rather than one bolted on
afterwards.

Attached (lock_on_create_rev2.patch) is an example of how this can be
done, that fits with the current design. I can trivially write the
same code using ctypes as well. The only slight ugliness is having to
deal with three sets of file-opening-flags, for the win32 kernel, for
C, and for python. The win is slightly simpler code, and better
compatability, see <https://bugs.launchpad.net/bzr/+bug/103731> and
attached (bzrlib.tests.per_lock.log) results of selftest.

Questions:
# Would a change along these lines be acceptable?
# Are there any expectations of the lock classes that aren't exercised in tests?
# Should the existing win32 classes be left in place for the moment at least?
# Would altering the design to avoid all the code duplication be warrented?
# Are locks only taken on byte string filenames, or is unicode used as well?
# How *are* you meant to do unicode exceptions in bazaar...

Martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: lock_on_create_rev2.patch
Type: application/octet-stream
Size: 2478 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20090610/04b3de6c/attachment-0002.obj 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: bzrlib.tests.per_lock.log
Type: application/octet-stream
Size: 26796 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20090610/04b3de6c/attachment-0003.obj 


More information about the bazaar mailing list