Merge lp:~abentley/bzr/lucid-launchpadlib into lp:bzr

Proposed by Aaron Bentley
Status: Merged
Merged at revision: 6541
Proposed branch: lp:~abentley/bzr/lucid-launchpadlib
Merge into: lp:bzr
Diff against target: 94 lines (+18/-32)
1 file modified
bzrlib/plugins/launchpad/lp_api.py (+18/-32)
To merge this branch: bzr merge lp:~abentley/bzr/lucid-launchpadlib
Reviewer Review Type Date Requested Status
Martin Packman (community) Approve
Aaron Bentley Pending
Review via email: mp+116275@code.launchpad.net

This proposal supersedes a proposal from 2012-07-20.

Description of the change

This branch updates the launchpad plugin to use launchpadlib 1.6.0, which
shipped in Lucid Lynx, instead of 1.5.1, which shipped with Karmic Koala. This
allows some crufty compatibility code to be dropped, and simplifies the implementation of lp:~abentley/bzr/find-proposal-revid.

To post a comment you must log in.
Revision history for this message
Martin Packman (gz) wrote : Posted in a previous version of this proposal

The mp is confused with lots of spurious changes as the merge target is lp:~abentley/bzr/dev rather than lp:bzr - was that deliberate?

General idea seems sensible though.

Revision history for this message
Martin Packman (gz) wrote :

Really wants a news entry, looks good otherwise.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/plugins/launchpad/lp_api.py'
2--- bzrlib/plugins/launchpad/lp_api.py 2011-12-19 13:23:58 +0000
3+++ bzrlib/plugins/launchpad/lp_api.py 2012-07-23 13:20:39 +0000
4@@ -1,4 +1,4 @@
5-# Copyright (C) 2009, 2010 Canonical Ltd
6+# Copyright (C) 2009-2012 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@@ -49,12 +49,12 @@
11 STAGING_SERVICE_ROOT,
12 Launchpad,
13 )
14-
15+from launchpadlib import uris
16
17 # Declare the minimum version of launchpadlib that we need in order to work.
18-# 1.5.1 is the version of launchpadlib packaged in Ubuntu 9.10, the most
19-# recent Ubuntu release at the time of writing.
20-MINIMUM_LAUNCHPADLIB_VERSION = (1, 5, 1)
21+# 1.6.0 is the version of launchpadlib packaged in Ubuntu 10.04, the most
22+# recent Ubuntu LTS release supported on the desktop at the time of writing.
23+MINIMUM_LAUNCHPADLIB_VERSION = (1, 6, 0)
24
25
26 def get_cache_directory():
27@@ -76,28 +76,14 @@
28 installed_version, installed_version)
29
30
31-# The older versions of launchpadlib only provided service root constants for
32-# edge and staging, whilst newer versions drop edge. Therefore service root
33-# URIs for which we do not always have constants are derived from the staging
34-# one, which does always exist.
35-#
36-# It is necessary to derive, rather than use hardcoded URIs because
37-# launchpadlib <= 1.5.4 requires service root URIs that end in a path of
38-# /beta/, whilst launchpadlib >= 1.5.5 requires service root URIs with no path
39-# info.
40-#
41-# Once we have a hard dependency on launchpadlib >= 1.5.4 we can replace all of
42-# bzr's local knowledge of individual Launchpad instances with use of the
43-# launchpadlib.uris module.
44-LAUNCHPAD_API_URLS = {
45- 'production': STAGING_SERVICE_ROOT.replace('api.staging.launchpad.net',
46- 'api.launchpad.net'),
47- 'qastaging': STAGING_SERVICE_ROOT.replace('api.staging.launchpad.net',
48- 'api.qastaging.launchpad.net'),
49- 'staging': STAGING_SERVICE_ROOT,
50- 'dev': STAGING_SERVICE_ROOT.replace('api.staging.launchpad.net',
51- 'api.launchpad.dev'),
52- }
53+def lookup_service_root(service_root):
54+ try:
55+ return uris.lookup_service_root(service_root)
56+ except ValueError:
57+ if service_root != 'qastaging':
58+ raise
59+ staging_root = uris.lookup_service_root('staging')
60+ return staging_root.replace('staging', 'qastaging')
61
62
63 def _get_api_url(service):
64@@ -114,8 +100,8 @@
65 else:
66 lp_instance = service._lp_instance
67 try:
68- return LAUNCHPAD_API_URLS[lp_instance]
69- except KeyError:
70+ return lookup_service_root(lp_instance)
71+ except ValueError:
72 raise InvalidLaunchpadInstance(lp_instance)
73
74
75@@ -135,8 +121,8 @@
76 launchpad = Launchpad.login_with(
77 'bzr', _get_api_url(service), cache_directory, timeout=timeout,
78 proxy_info=proxy_info)
79- # XXX: Work-around a minor security bug in launchpadlib 1.5.1, which would
80- # create this directory with default umask.
81+ # XXX: Work-around a minor security bug in launchpadlib < 1.6.3, which
82+ # would create this directory with default umask.
83 osutils.chmod_if_possible(cache_directory, 0700)
84 return launchpad
85
86@@ -210,7 +196,7 @@
87 if str(launchpad._root_uri) == STAGING_SERVICE_ROOT:
88 return url.replace('bazaar.launchpad.net',
89 'bazaar.staging.launchpad.net')
90- elif str(launchpad._root_uri) == LAUNCHPAD_API_URLS['qastaging']:
91+ elif str(launchpad._root_uri) == lookup_service_root('qastaging'):
92 return url.replace('bazaar.launchpad.net',
93 'bazaar.qastaging.launchpad.net')
94 return url