Rev 5736: (jameinel) Fix bug #397739, in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Wed Mar 23 15:03:18 UTC 2011


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 5736 [merge]
revision-id: pqm at pqm.ubuntu.com-20110323150313-b058qpny5xns1ztt
parent: pqm at pqm.ubuntu.com-20110323124059-jqxxfxum3f6loxdx
parent: john at arbash-meinel.com-20110323133631-5tb1frfv63ewfw7m
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2011-03-23 15:03:13 +0000
message:
  (jameinel) Fix bug #397739,
   resolve 'lp:foo' locally as long as we have a launchpad-login to use
   bzr+ssh. (John A Meinel)
modified:
  bzrlib/plugins/launchpad/lp_directory.py lp_indirect.py-20070126012204-de5rugwlt22c7u7e-1
  bzrlib/plugins/launchpad/test_lp_directory.py test_lp_indirect.py-20070126002743-oyle362tzv9cd8mi-1
  doc/en/release-notes/bzr-2.3.txt NEWS-20050323055033-4e00b5db738777ff
=== modified file 'bzrlib/plugins/launchpad/lp_directory.py'
--- a/bzrlib/plugins/launchpad/lp_directory.py	2011-01-26 19:34:58 +0000
+++ b/bzrlib/plugins/launchpad/lp_directory.py	2011-03-23 13:36:31 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2007-2010 Canonical Ltd
+# Copyright (C) 2007-2011 Canonical Ltd
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -65,10 +65,23 @@
         """See DirectoryService.look_up"""
         return self._resolve(url)
 
-    def _resolve(self, url,
-                 _request_factory=ResolveLaunchpadPathRequest,
-                 _lp_login=None):
-        """Resolve the base URL for this transport."""
+    def _resolve_locally(self, path):
+        # Launchpad is now capable of doing the short-name to long name
+        # resolution inside the bzr+ssh server. We aren't yet able to do so for
+        # HTTP urls. - jam 20110323
+        return {'urls': ['bzr+ssh://bazaar.launchpad.net/+branch/' + path]}
+
+    def _resolve_via_xmlrpc(self, path, url, _request_factory):
+        service = LaunchpadService.for_url(url)
+        resolve = _request_factory(path)
+        try:
+            result = resolve.submit(service)
+        except xmlrpclib.Fault, fault:
+            raise errors.InvalidURL(
+                path=url, extra=fault.faultString)
+        return result
+
+    def _update_url_scheme(self, url):
         # Do ubuntu: and debianlp: expansions.
         scheme, netloc, path, query, fragment = urlsplit(url)
         if scheme in ('ubuntu', 'debianlp'):
@@ -106,22 +119,30 @@
                 series=series,
                 project=project)
             scheme, netloc, path, query, fragment = urlsplit(url)
-        service = LaunchpadService.for_url(url)
-        if _lp_login is None:
-            _lp_login = get_lp_login()
-        path = path.strip('/')
+        return url, path
+
+    def _expand_user(self, path, url, lp_login):
         if path.startswith('~/'):
-            if _lp_login is None:
+            if lp_login is None:
                 raise errors.InvalidURL(path=url,
                     extra='Cannot resolve "~" to your username.'
                           ' See "bzr help launchpad-login"')
-            path = '~' + _lp_login + path[1:]
-        resolve = _request_factory(path)
-        try:
-            result = resolve.submit(service)
-        except xmlrpclib.Fault, fault:
-            raise errors.InvalidURL(
-                path=url, extra=fault.faultString)
+            path = '~' + lp_login + path[1:]
+        return path
+
+    def _resolve(self, url,
+                 _request_factory=ResolveLaunchpadPathRequest,
+                 _lp_login=None):
+        """Resolve the base URL for this transport."""
+        url, path = self._update_url_scheme(url)
+        if _lp_login is None:
+            _lp_login = get_lp_login()
+        path = path.strip('/')
+        path = self._expand_user(path, url, _lp_login)
+        if _lp_login is not None:
+            result = self._resolve_locally(path)
+        else:
+            result = self._resolve_via_xmlrpc(path, url, _request_factory)
 
         if 'launchpad' in debug.debug_flags:
             trace.mutter("resolve_lp_path(%r) == %r", url, result)

=== modified file 'bzrlib/plugins/launchpad/test_lp_directory.py'
--- a/bzrlib/plugins/launchpad/test_lp_directory.py	2011-01-17 06:26:35 +0000
+++ b/bzrlib/plugins/launchpad/test_lp_directory.py	2011-03-23 15:03:13 +0000
@@ -180,16 +180,16 @@
         self.assertEquals('http://bazaar.launchpad.net/~apt/apt/devel',
                           directory._resolve('lp:///apt', factory))
 
-    def test_rewrite_bzr_ssh_launchpad_net(self):
+    def test_with_login_avoid_resolve_factory(self):
         # Test that bzr+ssh URLs get rewritten to include the user's
         # Launchpad ID (assuming we know the Launchpad ID).
         factory = FakeResolveFactory(
             self, 'apt', dict(urls=[
-                    'bzr+ssh://bazaar.launchpad.net/~apt/apt/devel',
+                    'bzr+ssh://my-super-custom/special/devel',
                     'http://bazaar.launchpad.net/~apt/apt/devel']))
         directory = LaunchpadDirectory()
         self.assertEquals(
-            'bzr+ssh://bazaar.launchpad.net/~apt/apt/devel',
+            'bzr+ssh://bazaar.launchpad.net/+branch/apt',
             directory._resolve('lp:///apt', factory, _lp_login='username'))
 
     def test_no_rewrite_of_other_bzr_ssh(self):
@@ -212,15 +212,15 @@
     def test_resolve_tilde_to_user(self):
         factory = FakeResolveFactory(
             self, '~username/apt/test', dict(urls=[
-                    'bzr+ssh://bazaar.launchpad.net/~username/apt/test']))
+                'bzr+ssh://bazaar.launchpad.net/+branch/~username/apt/test']))
         directory = LaunchpadDirectory()
         self.assertEquals(
-            'bzr+ssh://bazaar.launchpad.net/~username/apt/test',
+            'bzr+ssh://bazaar.launchpad.net/+branch/~username/apt/test',
             directory._resolve('lp:~/apt/test', factory, _lp_login='username'))
         # Should also happen when the login is just set by config
         set_lp_login('username')
         self.assertEquals(
-            'bzr+ssh://bazaar.launchpad.net/~username/apt/test',
+            'bzr+ssh://bazaar.launchpad.net/+branch/~username/apt/test',
             directory._resolve('lp:~/apt/test', factory))
 
     def test_tilde_fails_no_login(self):

=== modified file 'doc/en/release-notes/bzr-2.3.txt'
--- a/doc/en/release-notes/bzr-2.3.txt	2011-03-23 05:15:48 +0000
+++ b/doc/en/release-notes/bzr-2.3.txt	2011-03-23 15:03:13 +0000
@@ -26,6 +26,22 @@
 .. Improvements to existing commands, especially improved performance 
    or memory usage, or better results.
 
+* Getting all entries from ``CHKInventory.iter_entries_by_dir()`` has been
+  sped up dramatically for large trees. Iterating by dir is not the best
+  way to load data from a CHK inventory, so it preloads all the items in
+  the correct order. (With the gcc-tree, this changes it (re)reading 8GB
+  of CHK data, down to just 150MB.) This has noticeable affects for things
+  like building checkouts, etc.  (John Arbash Meinel, #737234)
+
+* Resolve ``lp:FOO`` urls locally rather than doing an XMLRPC request if
+  the user has done ``bzr launchpad-login``. The bzr+ssh URLs were already
+  being handed off to the remote server anyway (xmlrpc has been mapping
+  ``lp:bzr`` to ``bzr+ssh://bazaar.launchpad.net/+branch/bzr``, rather
+  than ``bzr+ssh://bazaar.launchpad.net/~bzr-pqm/bzr/bzr.dev`` for a few
+  months now.) By doing it ourselves, we can cut out substantial startup
+  time. From Netherlands to London it was taking 368ms to do the XMLRPC
+  call as much as 2s from Sydney. (John Arbash Meinel, #397739)
+
 Bug Fixes
 *********
 




More information about the bazaar-commits mailing list