Rev 3212: Extends the launchpad plugin's implementation of lp spec urls (Tim Penhey) in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Tue Feb 5 04:00:30 GMT 2008
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 3212
revision-id:pqm at pqm.ubuntu.com-20080205040018-f8a9czbkg30yhfh0
parent: pqm at pqm.ubuntu.com-20080201053934-q32y2nk5vvo13c6v
parent: ian.clatworthy at internode.on.net-20080205022804-5j9sm73zd2j70fb9
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2008-02-05 04:00:18 +0000
message:
Extends the launchpad plugin's implementation of lp spec urls (Tim Penhey)
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/plugins/launchpad/__init__.py __init__.py-20060315182712-2d5feebd2a1032dc
bzrlib/plugins/launchpad/lp_indirect.py lp_indirect.py-20070126012204-de5rugwlt22c7u7e-1
bzrlib/plugins/launchpad/lp_registration.py lp_registration.py-20060315190948-daa617eafe3a8d48
bzrlib/plugins/launchpad/test_lp_indirect.py test_lp_indirect.py-20070126002743-oyle362tzv9cd8mi-1
------------------------------------------------------------
revno: 3211.1.1
revision-id:ian.clatworthy at internode.on.net-20080205022804-5j9sm73zd2j70fb9
parent: pqm at pqm.ubuntu.com-20080201053934-q32y2nk5vvo13c6v
parent: tim.penhey at canonical.com-20080203205508-crvpfbamumwi2p32
committer: Ian Clatworthy <ian.clatworthy at internode.on.net>
branch nick: ianc-integration
timestamp: Tue 2008-02-05 12:28:04 +1000
message:
Extends the launchpad plugin's implementation of lp spec urls (Tim Penhey)
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/plugins/launchpad/__init__.py __init__.py-20060315182712-2d5feebd2a1032dc
bzrlib/plugins/launchpad/lp_indirect.py lp_indirect.py-20070126012204-de5rugwlt22c7u7e-1
bzrlib/plugins/launchpad/lp_registration.py lp_registration.py-20060315190948-daa617eafe3a8d48
bzrlib/plugins/launchpad/test_lp_indirect.py test_lp_indirect.py-20070126002743-oyle362tzv9cd8mi-1
------------------------------------------------------------
revno: 3193.5.3
revision-id:tim.penhey at canonical.com-20080203205508-crvpfbamumwi2p32
parent: tim.penhey at canonical.com-20080122231121-1wc2sijixibsbt08
committer: Tim Penhey <tim.penhey at canonical.com>
branch nick: extending-lp-spec
timestamp: Mon 2008-02-04 09:55:08 +1300
message:
Tweaks following review.
modified:
NEWS NEWS-20050323055033-4e00b5db738777ff
bzrlib/plugins/launchpad/__init__.py __init__.py-20060315182712-2d5feebd2a1032dc
------------------------------------------------------------
revno: 3193.5.2
revision-id:tim.penhey at canonical.com-20080122231121-1wc2sijixibsbt08
parent: tim.penhey at canonical.com-20080122084050-af9b4nqlg046z6bc
committer: Tim Penhey <tim.penhey at canonical.com>
branch nick: extending-lp-spec
timestamp: Wed 2008-01-23 12:11:21 +1300
message:
Updated the tests to handle unknown launchpad instances.
modified:
bzrlib/plugins/launchpad/__init__.py __init__.py-20060315182712-2d5feebd2a1032dc
bzrlib/plugins/launchpad/lp_registration.py lp_registration.py-20060315190948-daa617eafe3a8d48
bzrlib/plugins/launchpad/test_lp_indirect.py test_lp_indirect.py-20070126002743-oyle362tzv9cd8mi-1
------------------------------------------------------------
revno: 3193.5.1
revision-id:tim.penhey at canonical.com-20080122084050-af9b4nqlg046z6bc
parent: pqm at pqm.ubuntu.com-20080118055224-sskoia4bcpxd8wzu
committer: Tim Penhey <tim.penhey at canonical.com>
branch nick: extending-lp-spec
timestamp: Tue 2008-01-22 21:40:50 +1300
message:
Mostly working, just need to update the tests for lp://dev
modified:
bzrlib/plugins/launchpad/__init__.py __init__.py-20060315182712-2d5feebd2a1032dc
bzrlib/plugins/launchpad/lp_indirect.py lp_indirect.py-20070126012204-de5rugwlt22c7u7e-1
bzrlib/plugins/launchpad/lp_registration.py lp_registration.py-20060315190948-daa617eafe3a8d48
=== modified file 'NEWS'
--- a/NEWS 2008-02-01 05:39:34 +0000
+++ b/NEWS 2008-02-05 02:28:04 +0000
@@ -35,6 +35,15 @@
client, and sends less data to the server to request the revisions.
(Andrew Bennetts, Robert Collins, #178353)
+ * The launchpad plugin now handles lp urls of the form
+ ``lp://staging/``, ``lp://demo/``, ``lp://dev/`` to use the appropriate
+ launchpad instance to do the resolution of the branch identities.
+ This is primarily of use to Launchpad developers, but can also
+ be used by other users who want to try out Launchpad as
+ a branch location without messing up their public Launchpad
+ account. Branches that are pushed to the staging environment
+ have an expected lifetime of one day. (Tim Penhey)
+
IMPROVEMENTS:
* Fetching between different repository formats with compatible models now
=== modified file 'bzrlib/plugins/launchpad/__init__.py'
--- a/bzrlib/plugins/launchpad/__init__.py 2008-01-25 11:52:56 +0000
+++ b/bzrlib/plugins/launchpad/__init__.py 2008-02-05 02:28:04 +0000
@@ -176,20 +176,21 @@
'bzrlib.plugins.launchpad.lp_indirect',
'LaunchpadTransport')
-register_lazy_transport(
- 'lp://',
- 'bzrlib.plugins.launchpad.lp_indirect',
- 'LaunchpadTransport')
def test_suite():
"""Called by bzrlib to fetch tests for this plugin"""
from unittest import TestSuite, TestLoader
from bzrlib.plugins.launchpad import (
- test_register, test_lp_indirect, test_account)
+ test_register, test_lp_indirect, test_lp_registration, test_account)
loader = TestLoader()
suite = TestSuite()
- for m in [test_register, test_lp_indirect, test_account]:
+ for m in [
+ test_account,
+ test_register,
+ test_lp_indirect,
+ test_lp_registration,
+ ]:
suite.addTests(loader.loadTestsFromModule(m))
return suite
=== modified file 'bzrlib/plugins/launchpad/lp_indirect.py'
--- a/bzrlib/plugins/launchpad/lp_indirect.py 2007-12-05 01:36:54 +0000
+++ b/bzrlib/plugins/launchpad/lp_indirect.py 2008-01-22 08:40:50 +0000
@@ -58,8 +58,10 @@
def __init__(self, base):
super(LaunchpadTransport, self).__init__(base)
# We only support URLs without a netloc
- netloc = urlsplit(base)[1]
- if netloc != '':
+ self.lp_instance = urlsplit(base)[1]
+ if self.lp_instance == '':
+ self.lp_instance = None
+ elif self.lp_instance not in LaunchpadService.LAUNCHPAD_INSTANCE:
raise errors.InvalidURL(path=base)
def _requires_launchpad_login(self, scheme, netloc, path, query,
@@ -80,7 +82,7 @@
path = urlsplit(abspath)[2].lstrip('/')
# Perform an XMLRPC request to resolve the path
resolve = _request_factory(path)
- service = LaunchpadService()
+ service = LaunchpadService(lp_instance=self.lp_instance)
try:
result = resolve.submit(service)
except xmlrpclib.Fault, fault:
=== modified file 'bzrlib/plugins/launchpad/lp_registration.py'
--- a/bzrlib/plugins/launchpad/lp_registration.py 2008-01-25 11:06:32 +0000
+++ b/bzrlib/plugins/launchpad/lp_registration.py 2008-02-05 02:28:04 +0000
@@ -32,27 +32,43 @@
export BZR_LP_XMLRPC_URL=http://xmlrpc.staging.launchpad.net/bazaar/
'''
+class InvalidLaunchpadInstance(errors.BzrError):
+
+ _fmt = "%(lp_instance)s is not a valid Launchpad instance."
+
+ def __init__(self, lp_instance):
+ errors.BzrError.__init__(self, lp_instance=lp_instance)
+
+
class LaunchpadService(object):
"""A service to talk to Launchpad via XMLRPC.
-
+
See http://bazaar-vcs.org/Specs/LaunchpadRpc for the methods we can call.
"""
- # NB: this should always end in a slash to avoid xmlrpclib appending
+ # NB: these should always end in a slash to avoid xmlrpclib appending
# '/RPC2'
- # We use edge because:
+ # We use edge as the default because:
# Beta users get redirected to it
# All users can use it
# There is a bug in the launchpad side where redirection causes an OOPS.
- DEFAULT_SERVICE_URL = 'https://xmlrpc.edge.launchpad.net/bazaar/'
+ LAUNCHPAD_INSTANCE = {
+ 'production': 'https://xmlrpc.launchpad.net/bazaar/',
+ 'edge': 'https://xmlrpc.edge.launchpad.net/bazaar/',
+ 'staging': 'https://xmlrpc.staging.launchpad.net/bazaar/',
+ 'demo': 'https://xmlrpc.demo.launchpad.net/bazaar/',
+ 'dev': 'http://xmlrpc.launchpad.dev/bazaar/',
+ }
+ DEFAULT_SERVICE_URL = LAUNCHPAD_INSTANCE['edge']
transport = None
registrant_email = None
registrant_password = None
- def __init__(self, transport=None):
+ def __init__(self, transport=None, lp_instance=None):
"""Construct a new service talking to the launchpad rpc server"""
+ self._lp_instance = lp_instance
if transport is None:
uri_type = urllib.splittype(self.service_url)[0]
if uri_type == 'https':
@@ -73,6 +89,11 @@
key = 'BZR_LP_XMLRPC_URL'
if key in os.environ:
return os.environ[key]
+ elif self._lp_instance is not None:
+ try:
+ return self.LAUNCHPAD_INSTANCE[self._lp_instance]
+ except KeyError:
+ raise InvalidLaunchpadInstance(self._lp_instance)
else:
return self.DEFAULT_SERVICE_URL
=== modified file 'bzrlib/plugins/launchpad/test_lp_indirect.py'
--- a/bzrlib/plugins/launchpad/test_lp_indirect.py 2007-11-27 01:01:01 +0000
+++ b/bzrlib/plugins/launchpad/test_lp_indirect.py 2008-01-22 23:11:21 +0000
@@ -40,6 +40,7 @@
return self
def submit(self, service):
+ self._service_url = service.service_url
return self._result
@@ -54,6 +55,22 @@
transport = LaunchpadTransport('lp:///')
self.assertEquals('http://bazaar.launchpad.net/~apt/apt/devel',
transport._resolve('lp:apt', factory))
+ # Make sure that resolve went to the production server.
+ self.assertEquals('https://xmlrpc.launchpad.net/bazaar/',
+ factory._service_url)
+
+ def test_staging(self):
+ """A launchpad url should map to a http url"""
+ factory = FakeResolveFactory(
+ self, 'apt', dict(urls=[
+ 'http://bazaar.staging.launchpad.net/~apt/apt/devel']))
+ url = 'lp://staging/apt'
+ transport = LaunchpadTransport(url)
+ self.assertEquals('http://bazaar.staging.launchpad.net/~apt/apt/devel',
+ transport._resolve(url, factory))
+ # Make sure that resolve went to the staging server.
+ self.assertEquals('https://xmlrpc.staging.launchpad.net/bazaar/',
+ factory._service_url)
def test_indirect_through_url(self):
"""A launchpad url should map to a http url"""
More information about the bazaar-commits
mailing list