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

Proposed by John A Meinel
Status: Rejected
Rejected by: John A Meinel
Proposed branch: lp:~jameinel/bzr/2.3-avoid-xmlrpc-ssh-397739
Merge into: lp:bzr/2.3
Diff against target: 142 lines (+53/-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 (+9/-0)
To merge this branch: bzr merge lp:~jameinel/bzr/2.3-avoid-xmlrpc-ssh-397739
Reviewer Review Type Date Requested Status
Vincent Ladeuil Approve
Jelmer Vernooij (community) Needs Information
Review via email: mp+54523@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

This is a quick fix for handling resolving of "lp:foo" style URLs.

I made sure to do the fix on a 2.3 branch, because it seems safe enough. We can land it on dev first, if we want to give it a little bit more time to simmer before landing it in the 2.3 series for release in Natty.

In real-world use cases, I've seen the XMLRPC request take more than a second. (Where it puts "Using saved push location lp..." and then waits a noticeable amount of time before I see the SSH connection starting.)

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

On Wed, 2011-03-23 at 13:40 +0000, John A Meinel wrote:
> For more details, see:
> https://code.launchpad.net/~jameinel/bzr/2.3-avoid-xmlrpc-ssh-397739/+merge/54523
>
> This is a quick fix for handling resolving of "lp:foo" style URLs.
>
> I made sure to do the fix on a 2.3 branch, because it seems safe enough. We can land it on dev first, if we want to give it a little bit more time to simmer before landing it in the 2.3 series for release in Natty.
>
> In real-world use cases, I've seen the XMLRPC request take more than a second. (Where it puts "Using saved push location lp..." and then waits a noticeable amount of time before I see the SSH connection starting.)
As mentioned on IRC, it seems like HTTP does support short URLs too. For
example, I'm able to branch from https://code.launchpad.net/bzr-svn . Is
there any reason this couldn't be used?

  review needsinformation

Cheers,

Jelmer

review: Needs Information
Revision history for this message
John A Meinel (jameinel) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 3/23/2011 3:06 PM, Jelmer Vernooij wrote:
> Review: Needs Information
> On Wed, 2011-03-23 at 13:40 +0000, John A Meinel wrote:
>> For more details, see:
>> https://code.launchpad.net/~jameinel/bzr/2.3-avoid-xmlrpc-ssh-397739/+merge/54523
>>
>> This is a quick fix for handling resolving of "lp:foo" style URLs.
>>
>> I made sure to do the fix on a 2.3 branch, because it seems safe enough. We can land it on dev first, if we want to give it a little bit more time to simmer before landing it in the 2.3 series for release in Natty.
>>
>> In real-world use cases, I've seen the XMLRPC request take more than a second. (Where it puts "Using saved push location lp..." and then waits a noticeable amount of time before I see the SSH connection starting.)
> As mentioned on IRC, it seems like HTTP does support short URLs too. For
> example, I'm able to branch from https://code.launchpad.net/bzr-svn . Is
> there any reason this couldn't be used?
>
> review needsinformation
>
> Cheers,
>
> Jelmer
>

https://code.launchpad.net/FOO is a trick we implemented a long time
ago. Before we had XMLRPC. It actually fakes a .bzr/branch/location file
to make it a 'lightweight checkout' to the real http location.

You can verify it by using

 https://code.launchpad.net/bzr-svn/.bzr/branch/location

I suppose we could revert to that old hack. I'm certainly impressed it
is still working correctly.

I think one loss is that it requires https. With a self-signed cert,
IIRC. While 'bazaar.launchpad.net' urls are all plain http.

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk2J/xoACgkQJdeBCYSNAANuuwCgyGcWBofhxDwWCi+e/e8wwcC9
DHAAoJhdRQZyjZWRKABx2LPLiUqGAbQq
=UYkr
-----END PGP SIGNATURE-----

Revision history for this message
Vincent Ladeuil (vila) wrote :

Nice one.

+1 on landing on trunk first.

review: Approve
Revision history for this message
Martin Pool (mbp) wrote :

That's great, thanks for fixing it!

I would not put this into 2.3 until we were sure it was ok in trunk;
there is a medium-high risk of interaction bugs.

Martin

Revision history for this message
John A Meinel (jameinel) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 3/24/2011 5:32 AM, Martin Pool wrote:
> That's great, thanks for fixing it!
>
> I would not put this into 2.3 until we were sure it was ok in trunk;
> there is a medium-high risk of interaction bugs.
>
> Martin

Looks like Andrew has already found one. Namely, stacking doesn't seem
to be triggering correctly on +branch/~user/project/branch listings.

We could change the local resolution to be absolute if it is fully
specified.

So if you supply 2 parts (or 3 parts with one being ubuntu/debian) then
we would use +branch, otherwise we just do the full expansion.

John
=:->

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk2K4c8ACgkQJdeBCYSNAAPD0wCeNa9xRqetVlGGrwQeWnzg79Uz
JIsAn0HdHD2HR2aGq8hSdbGT/F9jAx2u
=qSZ1
-----END PGP SIGNATURE-----

Revision history for this message
John A Meinel (jameinel) wrote :

This should not be merged directly into 2.3. Instead lp:~jameinel/bzr/2.3-three-part-resolution-stacking-741375 should be the branch that gets merged. Marking rejected.

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 13:40:44 +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-10 22:20:12 +0000
84+++ bzrlib/plugins/launchpad/test_lp_directory.py 2011-03-23 13:40:44 +0000
85@@ -167,16 +167,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@@ -199,15 +199,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 'doc/en/release-notes/bzr-2.3.txt'
126--- doc/en/release-notes/bzr-2.3.txt 2011-03-23 11:07:49 +0000
127+++ doc/en/release-notes/bzr-2.3.txt 2011-03-23 13:40:44 +0000
128@@ -33,6 +33,15 @@
129 of CHK data, down to just 150MB.) This has noticeable affects for things
130 like building checkouts, etc. (John Arbash Meinel, #737234)
131
132+* Resolve ``lp:FOO`` urls locally rather than doing an XMLRPC request if
133+ the user has done ``bzr launchpad-login``. The bzr+ssh URLs were already
134+ being handed off to the remote server anyway (xmlrpc has been mapping
135+ ``lp:bzr`` to ``bzr+ssh://bazaar.launchpad.net/+branch/bzr``, rather
136+ than ``bzr+ssh://bazaar.launchpad.net/~bzr-pqm/bzr/bzr.dev`` for a few
137+ months now.) By doing it ourselves, we can cut out substantial startup
138+ time. From Netherlands to London it was taking 368ms to do the XMLRPC
139+ call as much as 2s from Sydney. (John Arbash Meinel, #397739)
140+
141 Bug Fixes
142 *********
143

Subscribers

People subscribed via source and target branches