[MERGE][0.12.1] Ensure import dependencies

John Arbash Meinel john at arbash-meinel.com
Fri Nov 10 21:24:45 GMT 2006

I just did an audit of the whole bzr codebase (everything but tests and
benchmarks). And I tracked down quite a few places that were using
'bzrlib.foo' directly, without ever importing 'bzrlib.foo'.

There is a lot than can be done to clean up our imports. As I went
through this, I saw a lot of places that don't have their imports in
sorted order, and other things that I would like to fix. However, none
of it is strictly wrong, and I want to try and get a small patch so that
we feel safe back-porting it for an 0.12.1 release.

The patch doesn't make it terribly clear *why* I'm doing the imports,
because you don't see the later use of the module.

But basically, I just did a regex search for 'bzrlib\.[a-zA-Z]' to find
all of the places that we accessing a member of bzrlib. And then I saw
where they were using one that wasn't actually imported.

bzrlib.ui.ui_factory was the #1 offender. Though that gets imported very
early on (and probably won't change).

A couple more serious ones were in bzrdir.py which accesses both
repository and branch (and obviously workingtree in the past) without
importing any of them. add.py accesses bzrdir (to see if a directory is
a nested branch), branch.py accesses workingtree in a deprecated
function. Inventory accesses workingtree and workingtree access
inventory, both of which weren't importing the other one.

I also found that http/__init__.py was importing 'ui_factory' directly,
which means the function would never have worked (as is, it is only used
by the test suite). Since it would always be using a SilentUIFactory.

I did run the full test suite with the changes, and I ran a few commands
manually without plugins to make sure that everything still worked.

If we wanted, we could set up a smoke test in blackbox, which would just
run a few of the basic commands using run_bzr_subprocess.

Though some of them only happened under special circumstances (like "bzr
log -v" but not "bzr log").

So I'd like to get the attached patch merged into an 0.12.1 release, as
well as into bzr.dev.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0.12.1-audit-imports.patch
Type: text/x-patch
Size: 9681 bytes
Desc: not available
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20061110/6976c18b/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 254 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20061110/6976c18b/attachment.pgp 

More information about the bazaar mailing list