Multiple calls to BzrDir.open_branch() return different objects

Michael Ellerman michael at ellerman.id.au
Mon Feb 27 00:02:03 GMT 2006


I noticed something similar the other week, status opens the hashcache
three times because it creates three working_trees, all for the same
actual working tree.

So there might be a performance gain also.

cheers

On 2/24/06, Martin Pool <mbp at sourcefrog.net> wrote:
> 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'.
>
> I agree.  They should be lazily constructed and stored in the bzrdir.
>
> --
> Martin
>
>
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.2.1 (GNU/Linux)
>
> iD8DBQBD/pyEPGPKP6Cz6IsRAjOYAJ9U4hxMatHSoiW+1yEk8RstumeRfQCdE8tx
> RfJSN02t+ZWVtAglfTMrbbU=
> =o2bU
> -----END PGP SIGNATURE-----
>
>
>




More information about the bazaar mailing list