Rev 6541: (abentley) lp-find-proposal now ignores branch. (Aaron Bentley) in file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
Patch Queue Manager
pqm at pqm.ubuntu.com
Mon Jul 23 19:46:46 UTC 2012
At file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 6541 [merge]
revision-id: pqm at pqm.ubuntu.com-20120723194645-5a57w8fw122aei34
parent: pqm at pqm.ubuntu.com-20120723175645-92crzj8j7bfnuglm
parent: aaron at aaronbentley.com-20120723191905-bob8qh95hxnl12h9
committer: Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Mon 2012-07-23 19:46:45 +0000
message:
(abentley) lp-find-proposal now ignores branch. (Aaron Bentley)
modified:
bzrlib/plugins/launchpad/cmds.py cmds.py-20120310190900-ivsmwjx0w9s5gpm3-1
bzrlib/plugins/launchpad/lp_api.py lp_api.py-20090704082908-79il6zl4gugwl3wz-1
doc/en/release-notes/bzr-2.6.txt bzr2.6.txt-20120116134316-8w1xxom1c7vcu1t5-1
=== modified file 'bzrlib/plugins/launchpad/cmds.py'
--- a/bzrlib/plugins/launchpad/cmds.py 2012-03-12 14:35:26 +0000
+++ b/bzrlib/plugins/launchpad/cmds.py 2012-07-23 19:19:05 +0000
@@ -28,7 +28,6 @@
)
from bzrlib.errors import (
BzrCommandError,
- InvalidRevisionSpec,
InvalidURL,
NoPublicBranch,
NotBranchError,
@@ -335,16 +334,15 @@
__doc__ = """Find the proposal to merge this revision.
Finds the merge proposal(s) that discussed landing the specified revision.
- This works only if the selected branch was the merge proposal target, and
- if the merged_revno is recorded for the merge proposal. The proposal(s)
- are opened in a web browser.
+ This works only if the if the merged_revno was recorded for the merge
+ proposal. The proposal(s) are opened in a web browser.
- Any revision involved in the merge may be specified-- the revision in
- which the merge was performed, or one of the revisions that was merged.
+ Only the revision specified is searched for. To find the mainline
+ revision that merged it into mainline, use the "mainline" revision spec.
So, to find the merge proposal that reviewed line 1 of README::
- bzr lp-find-proposal -r annotate:README:1
+ bzr lp-find-proposal -r mainline:annotate:README:1
"""
takes_options = ['revision']
@@ -357,8 +355,11 @@
pb = ui.ui_factory.nested_progress_bar()
b.lock_read()
try:
- revno = self._find_merged_revno(revision, b, pb)
- merged = self._find_proposals(revno, b, pb)
+ if revision is None:
+ revision_id = b.last_revision()
+ else:
+ revision_id = revision[0].as_revision_id(b)
+ merged = self._find_proposals(revision_id, pb)
if len(merged) == 0:
raise BzrCommandError(gettext('No review found.'))
trace.note(gettext('%d proposals(s) found.') % len(merged))
@@ -368,43 +369,11 @@
b.unlock()
pb.finished()
- def _find_merged_revno(self, revision, b, pb):
- if revision is None:
- return b.revno()
- pb.update(gettext('Finding revision-id'))
- revision_id = revision[0].as_revision_id(b)
- # a revno spec is necessarily on the mainline.
- if self._is_revno_spec(revision[0]):
- merging_revision = revision_id
- else:
- graph = b.repository.get_graph()
- pb.update(gettext('Finding merge'))
- merging_revision = graph.find_lefthand_merger(
- revision_id, b.last_revision())
- if merging_revision is None:
- raise InvalidRevisionSpec(revision[0].user_spec, b)
- pb.update(gettext('Finding revno'))
- return b.revision_id_to_revno(merging_revision)
-
- def _find_proposals(self, revno, b, pb):
+ def _find_proposals(self, revision_id, pb):
from bzrlib.plugins.launchpad import (lp_api, lp_registration)
- launchpad = lp_api.login(lp_registration.LaunchpadService())
- pb.update(gettext('Finding Launchpad branch'))
- lpb = lp_api.LaunchpadBranch.from_bzr(launchpad, b,
- create_missing=False)
+ # "devel" because branches.getMergeProposals is not part of 1.0 API.
+ launchpad = lp_api.login(lp_registration.LaunchpadService(),
+ version='devel')
pb.update(gettext('Finding proposals'))
- return list(lpb.lp.getMergeProposals(status=['Merged'],
- merged_revnos=[revno]))
-
-
- @staticmethod
- def _is_revno_spec(spec):
- try:
- int(spec.user_spec)
- except ValueError:
- return False
- else:
- return True
-
-
-
+ return list(launchpad.branches.getMergeProposals(
+ merged_revision=revision_id))
=== modified file 'bzrlib/plugins/launchpad/lp_api.py'
--- a/bzrlib/plugins/launchpad/lp_api.py 2011-12-19 13:23:58 +0000
+++ b/bzrlib/plugins/launchpad/lp_api.py 2012-07-20 15:09:13 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2009, 2010 Canonical Ltd
+# Copyright (C) 2009-2012 Canonical Ltd
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -49,12 +49,12 @@
STAGING_SERVICE_ROOT,
Launchpad,
)
-
+from launchpadlib import uris
# Declare the minimum version of launchpadlib that we need in order to work.
-# 1.5.1 is the version of launchpadlib packaged in Ubuntu 9.10, the most
-# recent Ubuntu release at the time of writing.
-MINIMUM_LAUNCHPADLIB_VERSION = (1, 5, 1)
+# 1.6.0 is the version of launchpadlib packaged in Ubuntu 10.04, the most
+# recent Ubuntu LTS release supported on the desktop at the time of writing.
+MINIMUM_LAUNCHPADLIB_VERSION = (1, 6, 0)
def get_cache_directory():
@@ -76,28 +76,14 @@
installed_version, installed_version)
-# The older versions of launchpadlib only provided service root constants for
-# edge and staging, whilst newer versions drop edge. Therefore service root
-# URIs for which we do not always have constants are derived from the staging
-# one, which does always exist.
-#
-# It is necessary to derive, rather than use hardcoded URIs because
-# launchpadlib <= 1.5.4 requires service root URIs that end in a path of
-# /beta/, whilst launchpadlib >= 1.5.5 requires service root URIs with no path
-# info.
-#
-# Once we have a hard dependency on launchpadlib >= 1.5.4 we can replace all of
-# bzr's local knowledge of individual Launchpad instances with use of the
-# launchpadlib.uris module.
-LAUNCHPAD_API_URLS = {
- 'production': STAGING_SERVICE_ROOT.replace('api.staging.launchpad.net',
- 'api.launchpad.net'),
- 'qastaging': STAGING_SERVICE_ROOT.replace('api.staging.launchpad.net',
- 'api.qastaging.launchpad.net'),
- 'staging': STAGING_SERVICE_ROOT,
- 'dev': STAGING_SERVICE_ROOT.replace('api.staging.launchpad.net',
- 'api.launchpad.dev'),
- }
+def lookup_service_root(service_root):
+ try:
+ return uris.lookup_service_root(service_root)
+ except ValueError:
+ if service_root != 'qastaging':
+ raise
+ staging_root = uris.lookup_service_root('staging')
+ return staging_root.replace('staging', 'qastaging')
def _get_api_url(service):
@@ -114,8 +100,8 @@
else:
lp_instance = service._lp_instance
try:
- return LAUNCHPAD_API_URLS[lp_instance]
- except KeyError:
+ return lookup_service_root(lp_instance)
+ except ValueError:
raise InvalidLaunchpadInstance(lp_instance)
@@ -126,7 +112,8 @@
errors.BzrError.__init__(self, branch=branch, url=branch.base)
-def login(service, timeout=None, proxy_info=None):
+def login(service, timeout=None, proxy_info=None,
+ version=Launchpad.DEFAULT_VERSION):
"""Log in to the Launchpad API.
:return: The root `Launchpad` object from launchpadlib.
@@ -134,9 +121,9 @@
cache_directory = get_cache_directory()
launchpad = Launchpad.login_with(
'bzr', _get_api_url(service), cache_directory, timeout=timeout,
- proxy_info=proxy_info)
- # XXX: Work-around a minor security bug in launchpadlib 1.5.1, which would
- # create this directory with default umask.
+ proxy_info=proxy_info, version=version)
+ # XXX: Work-around a minor security bug in launchpadlib < 1.6.3, which
+ # would create this directory with default umask.
osutils.chmod_if_possible(cache_directory, 0700)
return launchpad
@@ -210,7 +197,7 @@
if str(launchpad._root_uri) == STAGING_SERVICE_ROOT:
return url.replace('bazaar.launchpad.net',
'bazaar.staging.launchpad.net')
- elif str(launchpad._root_uri) == LAUNCHPAD_API_URLS['qastaging']:
+ elif str(launchpad._root_uri) == lookup_service_root('qastaging'):
return url.replace('bazaar.launchpad.net',
'bazaar.qastaging.launchpad.net')
return url
=== modified file 'doc/en/release-notes/bzr-2.6.txt'
--- a/doc/en/release-notes/bzr-2.6.txt 2012-07-19 18:39:38 +0000
+++ b/doc/en/release-notes/bzr-2.6.txt 2012-07-23 19:46:45 +0000
@@ -24,8 +24,9 @@
Improvements
************
-.. Improvements to existing commands, especially improved performance
- or memory usage, or better results.
+``bzr lp-find-proposal`` now only cares about the revision-id that is
+specified, not the branch you use. This was enabled by a new API call in
+Launchpad's web service. (Aaron Bentley)
Bug Fixes
*********
@@ -47,8 +48,8 @@
Internals
*********
-.. Major internal changes, unlikely to be visible to users or plugin
- developers, but interesting for bzr developers.
+* The launchpad plugin now requires API 1.6.0 or later. This version shipped
+ with Ubuntu 9.10. (Aaron Bentley)
Testing
*******
More information about the bazaar-commits
mailing list