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

Robert Collins robertc at robertcollins.net
Thu Jan 26 22:17:24 GMT 2006


On Thu, 2006-01-26 at 13:14 -0600, John Arbash Meinel wrote:
> 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 ran into this on wednesday in branch-formats. I fixed a bug in the
implicit file creation of the LockFile class, and also altered the
initialisation logic to create the lockfile explicitly before trying to
lock.

> 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)

Yup, basically what I did. Except I considered creation the
LockableFiles object before the lock file existed 'wrong', so I do a
little workaround for that.

Rob

-- 
GPG key available at: <http://www.robertcollins.net/keys.txt>.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060127/1c9d84d1/attachment.pgp 


More information about the bazaar mailing list