[PING][MERGE][0.12] Avoid circular import for bzrlib.tree and bzrlib.revisiontree
John Arbash Meinel
john at arbash-meinel.com
Wed Oct 18 09:21:44 BST 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
PING: I'd really like to merge this for 0.12, especially since it should
fix:
https://launchpad.net/products/bzr/+bug/66349
We may need a more thorough code audit to uncover any other lazy import
bugs, but this is one of them.
(I also saw in passing that lockdir.py is using bzrlib.ui, but not
actually importing bzrlib.ui).
John
=:->
John Arbash Meinel wrote:
> The attached patch fixes bug:
> https://launchpad.net/products/bzr/+bug/63660
>
> RevisionTree was moved out of bzrlib.tree into bzrlib.revisiontree a
> while ago, but for compatibility it was imported back into bzrlib.tree.
> This caused a circular import between the two, so if
> 'bzrlib.revisiontree' got imported before 'bzrlib.tree' it would fail.
> The new lazy_import code triggered other bugs, because we no longer
> import things in the same order. (bug 66349).
>
> The discussion we've had is to add a new test which can ensure that
> every file can be imported directly, which will flush out circular
> imports like this. It won't catch other bugs where code inside functions
> expects things to be imported without actually importing it at the top.
>
> For example:
> import bzrlib.workingtree
>
> def do_something():
> return bzrlib.repository.Repository.open('.')
>
> Before lazy imports, that code would definitely have worked because
> bzrlib.workingtree directly imported bzrlib.repository, causing
> 'repository' to be a member of bzrlib. With lazy_imports, importing
> workingtree may not cause bzrlib.repository to be imported yet.
>
> Anyway, that still needs to be addressed, but for now, this avoids the
> bugs that we know about. :)
>
> John
> =:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.5 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFFNeQYJdeBCYSNAAMRAiKCAJ9bV3qxzk7IF9L05+tsTj+KI4M5JgCfTsHS
+mxxvTEyVcPQtNC2o4Eleow=
=dN6Y
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list