Rev 3077: Don't use sftp:// URLs as lp:/// translations when there's no Launchpad login. (Jonathan Lange) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Wed Dec 5 02:40:22 GMT 2007
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 3077
revision-id:pqm at pqm.ubuntu.com-20071205024011-bf20z11eucf3ltf1
parent: pqm at pqm.ubuntu.com-20071205003329-42n4davel9bplp04
parent: ian.clatworthy at internode.on.net-20071205020048-cp0qkj89kgj5ftjc
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Wed 2007-12-05 02:40:11 +0000
message:
Don't use sftp:// URLs as lp:/// translations when there's no Launchpad login. (Jonathan Lange)
modified:
bzrlib/plugins/launchpad/lp_indirect.py lp_indirect.py-20070126012204-de5rugwlt22c7u7e-1
bzrlib/plugins/launchpad/test_lp_indirect.py test_lp_indirect.py-20070126002743-oyle362tzv9cd8mi-1
------------------------------------------------------------
revno: 3076.1.1
revision-id:ian.clatworthy at internode.on.net-20071205020048-cp0qkj89kgj5ftjc
parent: pqm at pqm.ubuntu.com-20071205003329-42n4davel9bplp04
parent: jml at canonical.com-20071205013654-fndwypu6xea1rgh6
committer: Ian Clatworthy <ian.clatworthy at internode.on.net>
branch nick: ianc-integration
timestamp: Wed 2007-12-05 12:00:48 +1000
message:
Don't use sftp:// URLs as lp:/// translations when there's no Launchpad login. (Jonathan Lange)
modified:
bzrlib/plugins/launchpad/lp_indirect.py lp_indirect.py-20070126012204-de5rugwlt22c7u7e-1
bzrlib/plugins/launchpad/test_lp_indirect.py test_lp_indirect.py-20070126002743-oyle362tzv9cd8mi-1
------------------------------------------------------------
revno: 3031.2.4
revision-id:jml at canonical.com-20071205013654-fndwypu6xea1rgh6
parent: jml at canonical.com-20071127022541-cu7pkdu146035sfh
committer: jml at canonical.com
branch nick: lp-url-no-login
timestamp: Wed 2007-12-05 12:36:54 +1100
message:
Only split the URL once.
modified:
bzrlib/plugins/launchpad/lp_indirect.py lp_indirect.py-20070126012204-de5rugwlt22c7u7e-1
------------------------------------------------------------
revno: 3031.2.3
revision-id:jml at canonical.com-20071127022541-cu7pkdu146035sfh
parent: jml at canonical.com-20071127010101-ynzujv3cpmh1ahsi
committer: jml at canonical.com
branch nick: lp-url-no-login
timestamp: Tue 2007-11-27 13:25:41 +1100
message:
Make the test pass -- don't include sftp URLs if there's no lp login.
modified:
bzrlib/plugins/launchpad/lp_indirect.py lp_indirect.py-20070126012204-de5rugwlt22c7u7e-1
------------------------------------------------------------
revno: 3031.2.2
revision-id:jml at canonical.com-20071127010101-ynzujv3cpmh1ahsi
parent: jml at canonical.com-20071127010040-unf4jnnwaahve3an
committer: jml at canonical.com
branch nick: lp-url-no-login
timestamp: Tue 2007-11-27 12:01:01 +1100
message:
Failing test for skipping SFTP.
modified:
bzrlib/plugins/launchpad/test_lp_indirect.py test_lp_indirect.py-20070126002743-oyle362tzv9cd8mi-1
------------------------------------------------------------
revno: 3031.2.1
revision-id:jml at canonical.com-20071127010040-unf4jnnwaahve3an
parent: pqm at pqm.ubuntu.com-20071126224137-gnhd7r5hx7f0064k
committer: jml at canonical.com
branch nick: lp-url-no-login
timestamp: Tue 2007-11-27 12:00:40 +1100
message:
Factor out the method that determines if a URL is a LP url.
modified:
bzrlib/plugins/launchpad/lp_indirect.py lp_indirect.py-20070126012204-de5rugwlt22c7u7e-1
=== modified file 'bzrlib/plugins/launchpad/lp_indirect.py'
--- a/bzrlib/plugins/launchpad/lp_indirect.py 2007-10-31 19:47:45 +0000
+++ b/bzrlib/plugins/launchpad/lp_indirect.py 2007-12-05 01:36:54 +0000
@@ -62,6 +62,17 @@
if netloc != '':
raise errors.InvalidURL(path=base)
+ def _requires_launchpad_login(self, scheme, netloc, path, query,
+ fragment):
+ """Does the URL require a Launchpad login in order to be reached?
+
+ The URL is specified by its parsed components, as returned from
+ urlsplit.
+ """
+ return (scheme in ('bzr+ssh', 'sftp')
+ and (netloc.endswith('launchpad.net')
+ or netloc.endswith('launchpad.dev')))
+
def _resolve(self, abspath,
_request_factory=ResolveLaunchpadPathRequest,
_lp_login=None):
@@ -83,8 +94,8 @@
_lp_login = get_lp_login()
for url in result['urls']:
scheme, netloc, path, query, fragment = urlsplit(url)
- if scheme == 'bzr+ssh' and (netloc.endswith('launchpad.net') or
- netloc.endswith('launchpad.dev')):
+ if self._requires_launchpad_login(scheme, netloc, path, query,
+ fragment):
# Only accept launchpad.net bzr+ssh URLs if we know
# the user's Launchpad login:
if _lp_login is None:
=== modified file 'bzrlib/plugins/launchpad/test_lp_indirect.py'
--- a/bzrlib/plugins/launchpad/test_lp_indirect.py 2007-10-31 23:23:30 +0000
+++ b/bzrlib/plugins/launchpad/test_lp_indirect.py 2007-11-27 01:01:01 +0000
@@ -106,6 +106,18 @@
self.assertEquals('http://bazaar.launchpad.net/~apt/apt/devel',
transport._resolve('lp:///apt', factory))
+ def test_skip_sftp_launchpad_net_when_anonymous(self):
+ # Test that sftp://bazaar.launchpad.net gets skipped if
+ # Bazaar does not know the user's Launchpad ID:
+ self.assertEqual(None, get_lp_login())
+ factory = FakeResolveFactory(
+ self, 'apt', dict(urls=[
+ 'sftp://bazaar.launchpad.net/~apt/apt/devel',
+ 'http://bazaar.launchpad.net/~apt/apt/devel']))
+ transport = LaunchpadTransport('lp:///')
+ self.assertEquals('http://bazaar.launchpad.net/~apt/apt/devel',
+ transport._resolve('lp:///apt', factory))
+
def test_rewrite_bzr_ssh_launchpad_net(self):
# Test that bzr+ssh URLs get rewritten to include the user's
# Launchpad ID (assuming we know the Launchpad ID).
More information about the bazaar-commits
mailing list