Merge lp:~abentley/bzr/find-proposal-revid into lp:~abentley/bzr/dev

Proposed by Aaron Bentley
Status: Superseded
Proposed branch: lp:~abentley/bzr/find-proposal-revid
Merge into: lp:~abentley/bzr/dev
Prerequisite: lp:~abentley/bzr/lucid-launchpadlib
Diff against target: 111 lines (+18/-48)
2 files modified
bzrlib/plugins/launchpad/cmds.py (+15/-46)
bzrlib/plugins/launchpad/lp_api.py (+3/-2)
To merge this branch: bzr merge lp:~abentley/bzr/find-proposal-revid
Reviewer Review Type Date Requested Status
Aaron Bentley Pending
Review via email: mp+116009@code.launchpad.net

This proposal has been superseded by a proposal from 2012-07-23.

Commit message

Look up merge proposals by revision-id.

Description of the change

This branch changes the lp-find-proposal logic to use only the revision-id (not
revno and branch) to look up merge proposals.

Since the previous version used the branch in and revno API requests, it meant that lp-find-proposal only worked when the correct branch was specified. This way, it works no matter how the revision-id is determined.

The old code also required that the revision was on the mainline of the current branch, so for non-mainline revisions, it found the mainline revision that merged them. This code doesn't do that, but the user can prefix their revision spec with "mainline:" to restore that behaviour if it is desirable.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/plugins/launchpad/cmds.py'
2--- bzrlib/plugins/launchpad/cmds.py 2012-07-20 15:18:52 +0000
3+++ bzrlib/plugins/launchpad/cmds.py 2012-07-20 15:20:01 +0000
4@@ -335,16 +335,15 @@
5 __doc__ = """Find the proposal to merge this revision.
6
7 Finds the merge proposal(s) that discussed landing the specified revision.
8- This works only if the selected branch was the merge proposal target, and
9- if the merged_revno is recorded for the merge proposal. The proposal(s)
10- are opened in a web browser.
11+ This works only if the if the merged_revno was recorded for the merge
12+ proposal. The proposal(s) are opened in a web browser.
13
14- Any revision involved in the merge may be specified-- the revision in
15- which the merge was performed, or one of the revisions that was merged.
16+ Only the revision specified is searched for. To find the mainline
17+ revision that merged it into mainline, use the "mainline" revision spec.
18
19 So, to find the merge proposal that reviewed line 1 of README::
20
21- bzr lp-find-proposal -r annotate:README:1
22+ bzr lp-find-proposal -r mainline:annotate:README:1
23 """
24
25 takes_options = ['revision']
26@@ -357,8 +356,11 @@
27 pb = ui.ui_factory.nested_progress_bar()
28 b.lock_read()
29 try:
30- revno = self._find_merged_revno(revision, b, pb)
31- merged = self._find_proposals(revno, b, pb)
32+ if revision is None:
33+ revision_id = b.last_revision()
34+ else:
35+ revision_id = revision[0].as_revision_id(b)
36+ merged = self._find_proposals(revision_id, pb)
37 if len(merged) == 0:
38 raise BzrCommandError(gettext('No review found.'))
39 trace.note(gettext('%d proposals(s) found.') % len(merged))
40@@ -368,43 +370,10 @@
41 b.unlock()
42 pb.finished()
43
44- def _find_merged_revno(self, revision, b, pb):
45- if revision is None:
46- return b.revno()
47- pb.update(gettext('Finding revision-id'))
48- revision_id = revision[0].as_revision_id(b)
49- # a revno spec is necessarily on the mainline.
50- if self._is_revno_spec(revision[0]):
51- merging_revision = revision_id
52- else:
53- graph = b.repository.get_graph()
54- pb.update(gettext('Finding merge'))
55- merging_revision = graph.find_lefthand_merger(
56- revision_id, b.last_revision())
57- if merging_revision is None:
58- raise InvalidRevisionSpec(revision[0].user_spec, b)
59- pb.update(gettext('Finding revno'))
60- return b.revision_id_to_revno(merging_revision)
61-
62- def _find_proposals(self, revno, b, pb):
63+ def _find_proposals(self, revision_id, pb):
64 from bzrlib.plugins.launchpad import (lp_api, lp_registration)
65- launchpad = lp_api.login(lp_registration.LaunchpadService())
66- pb.update(gettext('Finding Launchpad branch'))
67- lpb = lp_api.LaunchpadBranch.from_bzr(launchpad, b,
68- create_missing=False)
69+ launchpad = lp_api.login(lp_registration.LaunchpadService(),
70+ version='devel')
71 pb.update(gettext('Finding proposals'))
72- return list(lpb.lp.getMergeProposals(status=['Merged'],
73- merged_revnos=[revno]))
74-
75-
76- @staticmethod
77- def _is_revno_spec(spec):
78- try:
79- int(spec.user_spec)
80- except ValueError:
81- return False
82- else:
83- return True
84-
85-
86-
87+ return list(launchpad.branches.getMergeProposals(
88+ merged_revision=revision_id))
89
90=== modified file 'bzrlib/plugins/launchpad/lp_api.py'
91--- bzrlib/plugins/launchpad/lp_api.py 2012-07-20 15:18:52 +0000
92+++ bzrlib/plugins/launchpad/lp_api.py 2012-07-20 15:20:01 +0000
93@@ -112,7 +112,8 @@
94 errors.BzrError.__init__(self, branch=branch, url=branch.base)
95
96
97-def login(service, timeout=None, proxy_info=None):
98+def login(service, timeout=None, proxy_info=None,
99+ version=Launchpad.DEFAULT_VERSION):
100 """Log in to the Launchpad API.
101
102 :return: The root `Launchpad` object from launchpadlib.
103@@ -120,7 +121,7 @@
104 cache_directory = get_cache_directory()
105 launchpad = Launchpad.login_with(
106 'bzr', _get_api_url(service), cache_directory, timeout=timeout,
107- proxy_info=proxy_info)
108+ proxy_info=proxy_info, version=version)
109 # XXX: Work-around a minor security bug in launchpadlib < 1.6.3, which
110 # would create this directory with default umask.
111 osutils.chmod_if_possible(cache_directory, 0700)

Subscribers

People subscribed via source and target branches

to all changes: