Merge lp:~lifeless/bzr/propose-accepted into lp:bzr

Proposed by Robert Collins on 2010-05-21
Status: Rejected
Rejected by: Robert Collins on 2010-05-21
Proposed branch: lp:~lifeless/bzr/propose-accepted
Merge into: lp:bzr
Diff against target: 128 lines (+39/-19)
2 files modified
bzrlib/plugins/launchpad/__init__.py (+4/-2)
bzrlib/plugins/launchpad/lp_propose.py (+35/-17)
To merge this branch: bzr merge lp:~lifeless/bzr/propose-accepted
Reviewer Review Type Date Requested Status
bzr-core 2010-05-21 Pending
Review via email: mp+25747@code.launchpad.net

Commit Message

testing more - sorry for the noise.

Description of the Change

woot. test. woot. Not accepted, noise noise noise. For good value, some
noise!

To post a comment you must log in.
Robert Collins (lifeless) wrote :

(and for clarity, staging was breaking on this, I tried there first).

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'bzrlib/plugins/launchpad/__init__.py'
2--- bzrlib/plugins/launchpad/__init__.py 2010-04-02 19:12:58 +0000
3+++ bzrlib/plugins/launchpad/__init__.py 2010-05-21 07:06:28 +0000
4@@ -310,6 +310,8 @@
5 help='Propose the merge on staging.'),
6 Option('message', short_name='m', type=unicode,
7 help='Commit message.'),
8+ Option('approve',
9+ help='Mark the proposal as approved immediately.'),
10 ListOption('review', short_name='R', type=unicode,
11 help='Requested reviewer and optional type.')]
12
13@@ -318,7 +320,7 @@
14 aliases = ['lp-submit', 'lp-propose']
15
16 def run(self, submit_branch=None, review=None, staging=False,
17- message=None):
18+ message=None, approve=False):
19 from bzrlib.plugins.launchpad import lp_propose
20 tree, branch, relpath = bzrdir.BzrDir.open_containing_tree_or_branch(
21 '.')
22@@ -338,7 +340,7 @@
23 else:
24 target = _mod_branch.Branch.open(submit_branch)
25 proposer = lp_propose.Proposer(tree, branch, target, message,
26- reviews, staging)
27+ reviews, staging, approve=approve)
28 proposer.check_proposal()
29 proposer.create_proposal()
30
31
32=== modified file 'bzrlib/plugins/launchpad/lp_propose.py'
33--- bzrlib/plugins/launchpad/lp_propose.py 2010-05-20 18:23:10 +0000
34+++ bzrlib/plugins/launchpad/lp_propose.py 2010-05-21 07:06:28 +0000
35@@ -55,7 +55,7 @@
36 hooks = ProposeMergeHooks()
37
38 def __init__(self, tree, source_branch, target_branch, message, reviews,
39- staging=False):
40+ staging=False, approve=False):
41 """Constructor.
42
43 :param tree: The working tree for the source branch.
44@@ -65,6 +65,10 @@
45 :param reviews: A list of tuples of reviewer, review type.
46 :param staging: If True, propose the merge against staging instead of
47 production.
48+ :param approve: If True, mark the new proposal as approved immediately.
49+ This is useful when a project permits some things to be approved
50+ by the submitter (e.g. merges between release and deployment
51+ branches).
52 """
53 self.tree = tree
54 if staging:
55@@ -81,6 +85,7 @@
56 self.target_branch = lp_api.LaunchpadBranch.from_bzr(
57 self.launchpad, target_branch)
58 self.commit_message = message
59+ # XXX: this is where bug lp:583638 could be tackled.
60 if reviews == []:
61 target_reviewer = self.target_branch.lp.reviewer
62 if target_reviewer is None:
63@@ -90,6 +95,7 @@
64 self.reviews = [(self.launchpad.people[reviewer], review_type)
65 for reviewer, review_type in
66 reviews]
67+ self.approve = approve
68
69 def get_comment(self, prerequisite_branch):
70 """Determine the initial comment for the merge proposal."""
71@@ -160,6 +166,24 @@
72 'prerequisite_branch': prerequisite_branch})
73 return prerequisite_branch
74
75+ def call_webservice(self, call, *args, **kwargs):
76+ """Make a call to the webservice, wrapping failures.
77+
78+ :param call: The call to make.
79+ :param *args: *args for the call.
80+ :param **kwargs: **kwargs for the call.
81+ :return: The result of calling call(*args, *kwargs).
82+ """
83+ try:
84+ return call(*args, **kwargs)
85+ except restful_errors.HTTPError, e:
86+ error_lines = []
87+ for line in e.content.splitlines():
88+ if line.startswith('Traceback (most recent call last):'):
89+ break
90+ error_lines.append(line)
91+ raise Exception(''.join(error_lines))
92+
93 def create_proposal(self):
94 """Perform the submission."""
95 prerequisite_branch = self._get_prerequisite_branch()
96@@ -175,22 +199,16 @@
97 review_types.append(review_type)
98 reviewers.append(reviewer.self_link)
99 initial_comment = self.get_comment(prerequisite_branch)
100- try:
101- mp = self.source_branch.lp.createMergeProposal(
102- target_branch=self.target_branch.lp,
103- prerequisite_branch=prereq,
104- initial_comment=initial_comment,
105- commit_message=self.commit_message, reviewers=reviewers,
106- review_types=review_types)
107- except restful_errors.HTTPError, e:
108- error_lines = []
109- for line in e.content.splitlines():
110- if line.startswith('Traceback (most recent call last):'):
111- break
112- error_lines.append(line)
113- raise Exception(''.join(error_lines))
114- else:
115- webbrowser.open(canonical_url(mp))
116+ mp = self.call_webservice(
117+ self.source_branch.lp.createMergeProposal,
118+ target_branch=self.target_branch.lp,
119+ prerequisite_branch=prereq,
120+ initial_comment=initial_comment,
121+ commit_message=self.commit_message, reviewers=reviewers,
122+ review_types=review_types)
123+ if self.approve:
124+ self.call_webservice(mp.setStatus, status='Approved')
125+ webbrowser.open(canonical_url(mp))
126
127
128 def modified_files(old_tree, new_tree):