Merge lp:~jameinel/bzr/2.3-avoid-xmlrpc-ssh-397739 into lp:bzr

Proposed by John A Meinel
Status: Merged
Approved by: John A Meinel
Approved revision: no longer in the source branch.
Merged at revision: 5736
Proposed branch: lp:~jameinel/bzr/2.3-avoid-xmlrpc-ssh-397739
Merge into: lp:bzr
Diff against target: 150 lines (+60/-23)
3 files modified
bzrlib/plugins/launchpad/lp_directory.py (+38/-17)
bzrlib/plugins/launchpad/test_lp_directory.py (+6/-6)
doc/en/release-notes/bzr-2.3.txt (+16/-0)
To merge this branch: bzr merge lp:~jameinel/bzr/2.3-avoid-xmlrpc-ssh-397739
Reviewer Review Type Date Requested Status
bzr-core Pending
Review via email: mp+54532@code.launchpad.net

Commit message

Fix bug #397739, resolve 'lp:foo' locally as long as we have a launchpad-login to use bzr+ssh.

Description of the change

landing on trunk first, even though approved for 2.3

To post a comment you must log in.
Revision history for this message
John A Meinel (jameinel) wrote :

sent to pqm by email

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/plugins/launchpad/lp_directory.py'
2--- bzrlib/plugins/launchpad/lp_directory.py 2011-01-26 19:34:58 +0000
3+++ bzrlib/plugins/launchpad/lp_directory.py 2011-03-23 14:23:37 +0000
4@@ -1,4 +1,4 @@
5-# Copyright (C) 2007-2010 Canonical Ltd
6+# Copyright (C) 2007-2011 Canonical Ltd
7 #
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10@@ -65,10 +65,23 @@
11 """See DirectoryService.look_up"""
12 return self._resolve(url)
13
14- def _resolve(self, url,
15- _request_factory=ResolveLaunchpadPathRequest,
16- _lp_login=None):
17- """Resolve the base URL for this transport."""
18+ def _resolve_locally(self, path):
19+ # Launchpad is now capable of doing the short-name to long name
20+ # resolution inside the bzr+ssh server. We aren't yet able to do so for
21+ # HTTP urls. - jam 20110323
22+ return {'urls': ['bzr+ssh://bazaar.launchpad.net/+branch/' + path]}
23+
24+ def _resolve_via_xmlrpc(self, path, url, _request_factory):
25+ service = LaunchpadService.for_url(url)
26+ resolve = _request_factory(path)
27+ try:
28+ result = resolve.submit(service)
29+ except xmlrpclib.Fault, fault:
30+ raise errors.InvalidURL(
31+ path=url, extra=fault.faultString)
32+ return result
33+
34+ def _update_url_scheme(self, url):
35 # Do ubuntu: and debianlp: expansions.
36 scheme, netloc, path, query, fragment = urlsplit(url)
37 if scheme in ('ubuntu', 'debianlp'):
38@@ -106,22 +119,30 @@
39 series=series,
40 project=project)
41 scheme, netloc, path, query, fragment = urlsplit(url)
42- service = LaunchpadService.for_url(url)
43- if _lp_login is None:
44- _lp_login = get_lp_login()
45- path = path.strip('/')
46+ return url, path
47+
48+ def _expand_user(self, path, url, lp_login):
49 if path.startswith('~/'):
50- if _lp_login is None:
51+ if lp_login is None:
52 raise errors.InvalidURL(path=url,
53 extra='Cannot resolve "~" to your username.'
54 ' See "bzr help launchpad-login"')
55- path = '~' + _lp_login + path[1:]
56- resolve = _request_factory(path)
57- try:
58- result = resolve.submit(service)
59- except xmlrpclib.Fault, fault:
60- raise errors.InvalidURL(
61- path=url, extra=fault.faultString)
62+ path = '~' + lp_login + path[1:]
63+ return path
64+
65+ def _resolve(self, url,
66+ _request_factory=ResolveLaunchpadPathRequest,
67+ _lp_login=None):
68+ """Resolve the base URL for this transport."""
69+ url, path = self._update_url_scheme(url)
70+ if _lp_login is None:
71+ _lp_login = get_lp_login()
72+ path = path.strip('/')
73+ path = self._expand_user(path, url, _lp_login)
74+ if _lp_login is not None:
75+ result = self._resolve_locally(path)
76+ else:
77+ result = self._resolve_via_xmlrpc(path, url, _request_factory)
78
79 if 'launchpad' in debug.debug_flags:
80 trace.mutter("resolve_lp_path(%r) == %r", url, result)
81
82=== modified file 'bzrlib/plugins/launchpad/test_lp_directory.py'
83--- bzrlib/plugins/launchpad/test_lp_directory.py 2011-01-17 06:26:35 +0000
84+++ bzrlib/plugins/launchpad/test_lp_directory.py 2011-03-23 14:23:37 +0000
85@@ -180,16 +180,16 @@
86 self.assertEquals('http://bazaar.launchpad.net/~apt/apt/devel',
87 directory._resolve('lp:///apt', factory))
88
89- def test_rewrite_bzr_ssh_launchpad_net(self):
90+ def test_with_login_avoid_resolve_factory(self):
91 # Test that bzr+ssh URLs get rewritten to include the user's
92 # Launchpad ID (assuming we know the Launchpad ID).
93 factory = FakeResolveFactory(
94 self, 'apt', dict(urls=[
95- 'bzr+ssh://bazaar.launchpad.net/~apt/apt/devel',
96+ 'bzr+ssh://my-super-custom/special/devel',
97 'http://bazaar.launchpad.net/~apt/apt/devel']))
98 directory = LaunchpadDirectory()
99 self.assertEquals(
100- 'bzr+ssh://bazaar.launchpad.net/~apt/apt/devel',
101+ 'bzr+ssh://bazaar.launchpad.net/+branch/apt',
102 directory._resolve('lp:///apt', factory, _lp_login='username'))
103
104 def test_no_rewrite_of_other_bzr_ssh(self):
105@@ -212,15 +212,15 @@
106 def test_resolve_tilde_to_user(self):
107 factory = FakeResolveFactory(
108 self, '~username/apt/test', dict(urls=[
109- 'bzr+ssh://bazaar.launchpad.net/~username/apt/test']))
110+ 'bzr+ssh://bazaar.launchpad.net/+branch/~username/apt/test']))
111 directory = LaunchpadDirectory()
112 self.assertEquals(
113- 'bzr+ssh://bazaar.launchpad.net/~username/apt/test',
114+ 'bzr+ssh://bazaar.launchpad.net/+branch/~username/apt/test',
115 directory._resolve('lp:~/apt/test', factory, _lp_login='username'))
116 # Should also happen when the login is just set by config
117 set_lp_login('username')
118 self.assertEquals(
119- 'bzr+ssh://bazaar.launchpad.net/~username/apt/test',
120+ 'bzr+ssh://bazaar.launchpad.net/+branch/~username/apt/test',
121 directory._resolve('lp:~/apt/test', factory))
122
123 def test_tilde_fails_no_login(self):
124
125=== modified file 'bzrlib/tests/test_inv.py'
126=== modified file 'doc/en/release-notes/bzr-2.3.txt'
127--- doc/en/release-notes/bzr-2.3.txt 2011-03-23 05:15:48 +0000
128+++ doc/en/release-notes/bzr-2.3.txt 2011-03-23 14:23:37 +0000
129@@ -26,6 +26,22 @@
130 .. Improvements to existing commands, especially improved performance
131 or memory usage, or better results.
132
133+* Getting all entries from ``CHKInventory.iter_entries_by_dir()`` has been
134+ sped up dramatically for large trees. Iterating by dir is not the best
135+ way to load data from a CHK inventory, so it preloads all the items in
136+ the correct order. (With the gcc-tree, this changes it (re)reading 8GB
137+ of CHK data, down to just 150MB.) This has noticeable affects for things
138+ like building checkouts, etc. (John Arbash Meinel, #737234)
139+
140+* Resolve ``lp:FOO`` urls locally rather than doing an XMLRPC request if
141+ the user has done ``bzr launchpad-login``. The bzr+ssh URLs were already
142+ being handed off to the remote server anyway (xmlrpc has been mapping
143+ ``lp:bzr`` to ``bzr+ssh://bazaar.launchpad.net/+branch/bzr``, rather
144+ than ``bzr+ssh://bazaar.launchpad.net/~bzr-pqm/bzr/bzr.dev`` for a few
145+ months now.) By doing it ourselves, we can cut out substantial startup
146+ time. From Netherlands to London it was taking 368ms to do the XMLRPC
147+ call as much as 2s from Sydney. (John Arbash Meinel, #397739)
148+
149 Bug Fixes
150 *********
151