[MERGE] init remote branches
John Arbash Meinel
john at arbash-meinel.com
Sun Jul 2 22:42:08 BST 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Aaron Bentley wrote:
> Wouter van Heyst wrote:
>>> - transport = get_transport(location)
>>> + transport = bzrlib.transport.get_transport(location)
>
> One style nitpick: I think it's nicer to importexceeding 80 chars, or
> particular names than to import the whole package. I prefer
> get_transport to bzrlib.transport.get_transport.
>
> - It's much shorter, so we don't wind up having to contort our code to
> avoid exceeding 80 chars.
> - It declares what we're using at the top, which can be useful to know.
> (For example, if someone removed get_transport from bzrlib.transport,
> we'd get an ImportError from importing builtins, instead of when we ran
> init.)
>
> Aaron
Oh, and one other reason to only import the module...
With our os-specific functions (like getcwd()) if we only import the
osutils module, then we can actually hijack the specific implementation
in the test suite, to make sure that the rest of the codebase does the
right thing.
I've used this for testing the normalization code, and having tests that
run on both Mac and Linux. (And test both code paths).
It is also helpful for plugins that need to hijack a given function, and
not trace down everywhere the function is imported.
We run into a few problems here and there (like directly importing
ui_factory, and then it doesn't get upcast to TextFactory or downcast to
SilentFactory at the right time.
John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQFEqD2wJdeBCYSNAAMRAlI6AJ9Q4yWneik0BN+KC90imwlSw6syrQCeILNl
qw+aWz2OpjZ0L7pru27+ygE=
=dLZd
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list