[BUG][MERGE] 'bzr upgrade' broken by lazy imports
Aaron Bentley
aaron.bentley at utoronto.ca
Tue Nov 7 19:10:38 GMT 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
John Arbash Meinel wrote:
> I fixed this specific dependency with the attached patch. I'd like to
> get it merged quickly. Also, we need to decide if it is worth releasing
> an 0.12.1. It is a regression, though the simple workaround is to just
> install bzrtools (which imports bzrlib.workingtree as part of it's startup).
Hmm. The code in question doesn't seem to be under test. At least,
when I remove bzrtools and run 'bzr selftest upgrade', no errors are
produced.
> I chose to fix this by doing 'from bzrlib.workingtree import Foo' rather
> than changing the global imports, because that is how all the other
> local functions work. And probably that is because of an import
> dependency issue. One nice thing about lazy imports is that they solve
> some import order issues, since you won't import something until it is used.
I agree being minimalist makes sense for this kind of bugfix.
> My initial feeling is to just change most code paths that use
> 'bzrilb.foo' to being 'from bzrlib import foo' at the beginning, and use
> 'foo.bar' later on.
That seems okay.
> === modified file bzrlib/bzrdir.py
> --- bzrlib/bzrdir.py
> +++ bzrlib/bzrdir.py
> @@ -1870,11 +1870,12 @@
> if name in bzrcontents:
> self.bzrdir.transport.delete(name)
> else:
> + from bzrlib.workingtree import WorkingTreeFormat3
> self.step('Upgrading working tree')
> self.bzrdir.transport.mkdir('checkout', mode=self.dir_mode)
> self.make_lock('checkout')
> self.put_format(
> - 'checkout', bzrlib.workingtree.WorkingTreeFormat3())
> + 'checkout', WorkingTreeFormat3())
> self.bzrdir.transport.delete_multi(
> self.garbage_inventories, self.pb)
> for entry in checkout_files:
This looks okay, but is there any way we can test it?
Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFFUNou0F+nu1YWqI0RAjnJAJ9FCEgpf30gM5NAjXnF++qz0Lwt+ACgiVXS
gIE6MAnw5YYRFXewp7Ee31Y=
=Wb8A
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list