Merge lp:~rockstar/launchpad/bug-520446 into lp:launchpad

Proposed by Paul Hummer
Status: Merged
Approved by: Graham Binns
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~rockstar/launchpad/bug-520446
Merge into: lp:launchpad
Prerequisite: lp:~rockstar/launchpad/bug-527450
Diff against target: 43 lines (+15/-0)
2 files modified
lib/lp/code/errors.py (+3/-0)
lib/lp/code/stories/webservice/xx-branchmergeproposal.txt (+12/-0)
To merge this branch: bzr merge lp:~rockstar/launchpad/bug-520446
Reviewer Review Type Date Requested Status
Graham Binns (community) code Approve
Review via email: mp+21025@code.launchpad.net

Description of the change

This branch fixes bug #520446. The exception being raised by
IBranch.createMergeProposal through the rest API was inconsistent with the rest
of Launchpad. All I did was catch the exception and re-raise it as a
ValueError.

To post a comment you must log in.
Revision history for this message
Graham Binns (gmb) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/code/errors.py'
2--- lib/lp/code/errors.py 2010-02-24 02:43:52 +0000
3+++ lib/lp/code/errors.py 2010-03-10 19:00:50 +0000
4@@ -17,6 +17,8 @@
5 'WrongBranchMergeProposal',
6 ]
7
8+from lazr.restful.declarations import webservice_error
9+
10
11 class BadBranchMergeProposalSearchContext(Exception):
12 """The context is not valid for a branch merge proposal search."""
13@@ -39,6 +41,7 @@
14
15 class BranchMergeProposalExists(InvalidBranchMergeProposal):
16 """Raised if there is already a matching BranchMergeProposal."""
17+ webservice_error(400) #Bad request.
18
19
20 class ReviewNotPending(Exception):
21
22=== modified file 'lib/lp/code/stories/webservice/xx-branchmergeproposal.txt'
23--- lib/lp/code/stories/webservice/xx-branchmergeproposal.txt 2010-03-09 17:30:18 +0000
24+++ lib/lp/code/stories/webservice/xx-branchmergeproposal.txt 2010-03-10 19:00:50 +0000
25@@ -76,6 +76,18 @@
26 votes_collection_link:
27 u'http://api.launchpad.dev/devel/~.../+merge/.../votes'
28
29+If we try and create the merge proposal again, we should get a ValueError.
30+
31+ >>> print registrant_webservice.named_post(
32+ ... source_url, 'createMergeProposal', target_branch=target_url,
33+ ... prerequisite_branch=prerequisite_url,
34+ ... initial_comment='Merge\nit!', needs_review=True,
35+ ... commit_message='It was merged!\n', reviewers=[reviewer_url],
36+ ... review_types=['green'])
37+ HTTP/1.1 500 Internal Server Error ...
38+ BranchMergeProposalExists: There is already a branch merge proposal
39+ registered for branch ... to land on ... that is still active.
40+
41 Our review request is listed in the votes collection.
42
43 >>> votes = webservice.get(