[MERGE][0.12] Avoid circular import for bzrlib.tree and bzrlib.revisiontree

John Arbash Meinel john at arbash-meinel.com
Mon Oct 16 07:57:37 BST 2006


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

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

iD8DBQFFMy1hJdeBCYSNAAMRAhd4AJ9XX7W+rWqNGL0nNsKOvFHvVmeIBACfbTkR
iBriqneg30JxjwgY29lU6xk=
=efo9
-----END PGP SIGNATURE-----
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: avoid_circular.patch
Url: https://lists.ubuntu.com/archives/bazaar/attachments/20061016/7f35ba44/attachment.diff 


More information about the bazaar mailing list