Rev 5248: (lifeless) Add a --approve to lp-propose for proposals that are in file:///home/pqm/archives/thelove/bzr/%2Btrunk/
Canonical.com Patch Queue Manager
pqm at pqm.ubuntu.com
Fri May 21 12:01:53 BST 2010
At file:///home/pqm/archives/thelove/bzr/%2Btrunk/
------------------------------------------------------------
revno: 5248 [merge]
revision-id: pqm at pqm.ubuntu.com-20100521110138-pyuhper87ny71bpz
parent: pqm at pqm.ubuntu.com-20100521084917-u9sae95g7s0nu2bf
parent: robertc at robertcollins.net-20100521042711-gt6x2vojrm4flnc9
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Fri 2010-05-21 12:01:38 +0100
message:
(lifeless) Add a --approve to lp-propose for proposals that are
self-approvable. (Robert Collins)
modified:
bzrlib/plugins/launchpad/__init__.py __init__.py-20060315182712-2d5feebd2a1032dc
bzrlib/plugins/launchpad/lp_propose.py lp_submit.py-20100120065117-penrmqruf596pui6-1
=== modified file 'bzrlib/plugins/launchpad/__init__.py'
--- a/bzrlib/plugins/launchpad/__init__.py 2010-04-02 19:12:58 +0000
+++ b/bzrlib/plugins/launchpad/__init__.py 2010-05-21 04:27:11 +0000
@@ -310,6 +310,8 @@
help='Propose the merge on staging.'),
Option('message', short_name='m', type=unicode,
help='Commit message.'),
+ Option('approve',
+ help='Mark the proposal as approved immediately.'),
ListOption('review', short_name='R', type=unicode,
help='Requested reviewer and optional type.')]
@@ -318,7 +320,7 @@
aliases = ['lp-submit', 'lp-propose']
def run(self, submit_branch=None, review=None, staging=False,
- message=None):
+ message=None, approve=False):
from bzrlib.plugins.launchpad import lp_propose
tree, branch, relpath = bzrdir.BzrDir.open_containing_tree_or_branch(
'.')
@@ -338,7 +340,7 @@
else:
target = _mod_branch.Branch.open(submit_branch)
proposer = lp_propose.Proposer(tree, branch, target, message,
- reviews, staging)
+ reviews, staging, approve=approve)
proposer.check_proposal()
proposer.create_proposal()
=== modified file 'bzrlib/plugins/launchpad/lp_propose.py'
--- a/bzrlib/plugins/launchpad/lp_propose.py 2010-05-21 07:17:13 +0000
+++ b/bzrlib/plugins/launchpad/lp_propose.py 2010-05-21 11:01:38 +0000
@@ -55,7 +55,7 @@
hooks = ProposeMergeHooks()
def __init__(self, tree, source_branch, target_branch, message, reviews,
- staging=False):
+ staging=False, approve=False):
"""Constructor.
:param tree: The working tree for the source branch.
@@ -65,6 +65,10 @@
:param reviews: A list of tuples of reviewer, review type.
:param staging: If True, propose the merge against staging instead of
production.
+ :param approve: If True, mark the new proposal as approved immediately.
+ This is useful when a project permits some things to be approved
+ by the submitter (e.g. merges between release and deployment
+ branches).
"""
self.tree = tree
if staging:
@@ -81,6 +85,7 @@
self.target_branch = lp_api.LaunchpadBranch.from_bzr(
self.launchpad, target_branch)
self.commit_message = message
+ # XXX: this is where bug lp:583638 could be tackled.
if reviews == []:
target_reviewer = self.target_branch.lp.reviewer
if target_reviewer is None:
@@ -90,6 +95,7 @@
self.reviews = [(self.launchpad.people[reviewer], review_type)
for reviewer, review_type in
reviews]
+ self.approve = approve
def get_comment(self, prerequisite_branch):
"""Determine the initial comment for the merge proposal."""
@@ -160,6 +166,24 @@
'prerequisite_branch': prerequisite_branch})
return prerequisite_branch
+ def call_webservice(self, call, *args, **kwargs):
+ """Make a call to the webservice, wrapping failures.
+
+ :param call: The call to make.
+ :param *args: *args for the call.
+ :param **kwargs: **kwargs for the call.
+ :return: The result of calling call(*args, *kwargs).
+ """
+ try:
+ return call(*args, **kwargs)
+ except restful_errors.HTTPError, e:
+ error_lines = []
+ for line in e.content.splitlines():
+ if line.startswith('Traceback (most recent call last):'):
+ break
+ error_lines.append(line)
+ raise Exception(''.join(error_lines))
+
def create_proposal(self):
"""Perform the submission."""
prerequisite_branch = self._get_prerequisite_branch()
@@ -175,22 +199,16 @@
review_types.append(review_type)
reviewers.append(reviewer.self_link)
initial_comment = self.get_comment(prerequisite_branch)
- try:
- mp = self.source_branch.lp.createMergeProposal(
- target_branch=self.target_branch.lp,
- prerequisite_branch=prereq,
- initial_comment=initial_comment,
- commit_message=self.commit_message, reviewers=reviewers,
- review_types=review_types)
- except restful_errors.HTTPError, e:
- error_lines = []
- for line in e.content.splitlines():
- if line.startswith('Traceback (most recent call last):'):
- break
- error_lines.append(line)
- raise Exception(''.join(error_lines))
- else:
- webbrowser.open(canonical_url(mp))
+ mp = self.call_webservice(
+ self.source_branch.lp.createMergeProposal,
+ target_branch=self.target_branch.lp,
+ prerequisite_branch=prereq,
+ initial_comment=initial_comment,
+ commit_message=self.commit_message, reviewers=reviewers,
+ review_types=review_types)
+ if self.approve:
+ self.call_webservice(mp.setStatus, status='Approved')
+ webbrowser.open(canonical_url(mp))
def modified_files(old_tree, new_tree):
More information about the bazaar-commits
mailing list