Rev 4042: Turn a bunch of imports into lazy imports. in http://bzr.arbash-meinel.com/branches/bzr/jam-integration

John Arbash Meinel john at arbash-meinel.com
Mon Mar 2 15:11:45 GMT 2009


At http://bzr.arbash-meinel.com/branches/bzr/jam-integration

------------------------------------------------------------
revno: 4042
revision-id: john at arbash-meinel.com-20090302151137-49g5p30mndfxxtv0
parent: jml at canonical.com-20090224041922-54j5zkxiyim5pz4r
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: jam-integration
timestamp: Mon 2009-03-02 09:11:37 -0600
message:
  Turn a bunch of imports into lazy imports.
  Fix a failing test due to a new error message.
-------------- next part --------------
=== modified file 'bzrlib/plugins/launchpad/__init__.py'
--- a/bzrlib/plugins/launchpad/__init__.py	2009-02-24 04:03:53 +0000
+++ b/bzrlib/plugins/launchpad/__init__.py	2009-03-02 15:11:37 +0000
@@ -21,9 +21,16 @@
 
 # see http://bazaar-vcs.org/Specs/BranchRegistrationTool
 
+from bzrlib.lazy_import import lazy_import
+lazy_import(globals(), """
 import webbrowser
 
-from bzrlib.branch import Branch
+from bzrlib import (
+    branch as _mod_branch,
+    trace,
+    )
+""")
+
 from bzrlib.commands import Command, Option, register_command
 from bzrlib.directory_service import directories
 from bzrlib.errors import (
@@ -37,7 +44,6 @@
     LaunchpadService,
     NotLaunchpadBranch,
     )
-from bzrlib.trace import note
 
 
 class cmd_register_branch(Command):
@@ -103,7 +109,7 @@
             DryRunLaunchpadService)
         if public_url is None:
             try:
-                b = Branch.open_containing('.')[0]
+                b = _mod_branch.Branch.open_containing('.')[0]
             except NotBranchError:
                 raise BzrCommandError('register-branch requires a public '
                     'branch url - see bzr help register-branch.')
@@ -154,7 +160,7 @@
         """Yield possible external locations for the branch at 'location'."""
         yield location
         try:
-            branch = Branch.open(location)
+            branch = _mod_branch.Branch.open(location)
         except NotBranchError:
             return
         branch_url = branch.get_public_branch()
@@ -176,7 +182,7 @@
         if location is None:
             location = u'.'
         web_url = self._get_web_url(LaunchpadService(), location)
-        note('Opening %s in web browser' % web_url)
+        trace.note('Opening %s in web browser' % web_url)
         if not dry_run:
             webbrowser.open(web_url)
 

=== modified file 'bzrlib/plugins/launchpad/test_lp_service.py'
--- a/bzrlib/plugins/launchpad/test_lp_service.py	2009-01-25 17:43:47 +0000
+++ b/bzrlib/plugins/launchpad/test_lp_service.py	2009-03-02 15:11:37 +0000
@@ -126,7 +126,7 @@
             NotLaunchpadBranch, service.get_web_url_from_branch_url,
             'bzr+ssh://example.com/~foo/bar/baz')
         self.assertEqual(
-            'bzr+ssh://example.com/~foo/bar/baz is not hosted on Launchpad.',
+            'bzr+ssh://example.com/~foo/bar/baz is not registered on Launchpad.',
             str(error))
 
     def test_dodgy_launchpad_url(self):



More information about the bazaar-commits mailing list