[BUG] win32 - can't create branch because of locking issue

John Arbash Meinel john at arbash-meinel.com
Thu Jan 26 19:14:24 GMT 2006


I'm really wondering what is going on with Linux file locking,
considering how different windows locking is.

The specific problem is that in BzrBranch._make_control we do this:

  self.control_files._transport.mkdir_multi([cfe(d) for d in dirs],
          mode=self.control_files._dir_mode)
  self.control_files.lock_write()
  try:
      for file, content in files:
          self.control_files.put_utf8(file, content)
      mutter('created control directory in ' + self.base)
  finally:
      self.control_files.unlock()

Which is a little bit odd, because one of the files that we are creating
is the '.bzr/branch-lock' file, which supposedly
control_files.lock_write() is locking.

What I really don't understand is how 'control files' has anything to
lock, since the file hasn't been created yet. My best guess is that our
Windows locks will actually create the file if it doesn't exist yet. The
problem being we are trying to replace a locked file, which Windows
won't let us do.

I realize that put_utf8 wants to take out a write lock, and the reason
we wrap ourselves in try/finally is so that we don't keep creating and
letting go of the write lock.

Attached is the patch I wrote to get around the problem. (Committed in
my win32 branch)

John
=:->

-------------- next part --------------
A non-text attachment was scrubbed...
Name: create-lock-early-in-init.patch
Type: text/x-patch
Size: 1006 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060126/b861d976/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 249 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060126/b861d976/attachment.pgp 


More information about the bazaar mailing list