Multiple calls to BzrDir.open_branch() return different objects

Robert Collins robertc at robertcollins.net
Tue Feb 28 00:22:16 GMT 2006


On Thu, 2006-02-23 at 22:57 -0600, John A Meinel wrote:
> Because of how locking works, it seems to me that multiple calls to
> BzrDir.open_branch() or open_repository() or open_working_tree() should
> return the same object.
> 
> Otherwise doing:
> 
> dir = BzrDir.open(path)
> branch = BzrDir.open_branch()
> branch.lock()
> try:
>   do_something(dir.open_working_tree())
> finally:
>   branch.unlock()
> 
> Will probably cause a deadlock if anything in do_something calls
> 'wt.branch'.
> 
> The current code isn't terrible. It just doesn't seem optimal.

I deliberately did not cache the objects in the bzrdir for a number of
reasons. Firstly the deadlock issue: there are many ways we can
deadlock, and this is possibly just the simplest. Other ways include:
- file system aliasing
- opening the same bzrdir independently

Secondly, as we have said in discussion that the 'right way' to access
things is hierarchically: tree.branch.repository; branch.repository; and
repository, then the deadlock you describe should be impossible *unless*
we are violating that precept, and I would actually like to know when we
violate it as it will help clear up layering problems and make things
more managable.

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: 191 bytes
Desc: This is a digitally signed message part
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20060228/91af0ce1/attachment.pgp 


More information about the bazaar mailing list