Merge lp:~thumper/launchpad/lp-code-errors into lp:launchpad/db-devel

Proposed by Tim Penhey
Status: Merged
Approved by: Michael Hudson-Doyle
Approved revision: not available
Merged at revision: 8757
Proposed branch: lp:~thumper/launchpad/lp-code-errors
Merge into: lp:launchpad/db-devel
Prerequisite: lp:~thumper/launchpad/claim-review-into-model
Diff against target: 264 lines (+66/-52)
9 files modified
lib/lp/code/browser/branch.py (+1/-1)
lib/lp/code/browser/branchmergeproposal.py (+2/-2)
lib/lp/code/errors.py (+48/-0)
lib/lp/code/interfaces/branchmergeproposal.py (+1/-38)
lib/lp/code/mail/codehandler.py (+2/-2)
lib/lp/code/model/branch.py (+3/-2)
lib/lp/code/model/branchmergeproposal.py (+4/-3)
lib/lp/code/model/tests/test_branch.py (+2/-2)
lib/lp/code/model/tests/test_branchmergeproposals.py (+3/-2)
To merge this branch: bzr merge lp:~thumper/launchpad/lp-code-errors
Reviewer Review Type Date Requested Status
Michael Hudson-Doyle Approve
Review via email: mp+15724@code.launchpad.net

Commit message

Create the lp.code.errors module and start moving exceptions across.

To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) wrote :

Cherry picked the new errors file out.

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Looks like a good start for this file :-)

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/code/browser/branch.py'
2--- lib/lp/code/browser/branch.py 2009-11-25 23:25:51 +0000
3+++ lib/lp/code/browser/branch.py 2009-12-07 02:20:33 +0000
4@@ -80,10 +80,10 @@
5 latest_proposals_for_each_branch)
6 from lp.code.enums import (
7 BranchLifecycleStatus, BranchType, UICreatableBranchType)
8+from lp.code.errors import InvalidBranchMergeProposal
9 from lp.code.interfaces.branch import (
10 BranchCreationForbidden, BranchExists, IBranch,
11 user_has_special_branch_access)
12-from lp.code.interfaces.branchmergeproposal import InvalidBranchMergeProposal
13 from lp.code.interfaces.branchtarget import IBranchTarget
14 from lp.code.interfaces.codeimport import CodeImportReviewStatus
15 from lp.code.interfaces.codeimportjob import (
16
17=== modified file 'lib/lp/code/browser/branchmergeproposal.py'
18--- lib/lp/code/browser/branchmergeproposal.py 2009-11-24 01:53:32 +0000
19+++ lib/lp/code/browser/branchmergeproposal.py 2009-12-07 02:20:34 +0000
20@@ -71,8 +71,8 @@
21 from lp.code.enums import (
22 BranchMergeProposalStatus, BranchType, CodeReviewNotificationLevel,
23 CodeReviewVote)
24-from lp.code.interfaces.branchmergeproposal import (
25- IBranchMergeProposal, WrongBranchMergeProposal)
26+from lp.code.errors import WrongBranchMergeProposal
27+from lp.code.interfaces.branchmergeproposal import IBranchMergeProposal
28 from lp.code.interfaces.codereviewcomment import ICodeReviewComment
29 from lp.code.interfaces.codereviewvote import (
30 ICodeReviewVoteReference)
31
32=== added file 'lib/lp/code/errors.py'
33--- lib/lp/code/errors.py 1970-01-01 00:00:00 +0000
34+++ lib/lp/code/errors.py 2009-12-07 02:20:33 +0000
35@@ -0,0 +1,48 @@
36+# Copyright 2009 Canonical Ltd. This software is licensed under the
37+# GNU Affero General Public License version 3 (see the file LICENSE).
38+
39+"""Errors used in the lp/code modules."""
40+
41+__metaclass__ = type
42+__all__ = [
43+ 'BadBranchMergeProposalSearchContext',
44+ 'BadStateTransition',
45+ 'BranchMergeProposalExists',
46+ 'InvalidBranchMergeProposal',
47+ 'UserNotBranchReviewer',
48+ 'WrongBranchMergeProposal',
49+]
50+
51+
52+class BadBranchMergeProposalSearchContext(Exception):
53+ """The context is not valid for a branch merge proposal search."""
54+
55+
56+class BadStateTransition(Exception):
57+ """The user requested a state transition that is not possible."""
58+
59+
60+class InvalidBranchMergeProposal(Exception):
61+ """Raised during the creation of a new branch merge proposal.
62+
63+ The text of the exception is the rule violation.
64+ """
65+
66+
67+class BranchMergeProposalExists(InvalidBranchMergeProposal):
68+ """Raised if there is already a matching BranchMergeProposal."""
69+
70+
71+class UserNotBranchReviewer(Exception):
72+ """The user who attempted to review the merge proposal isn't a reviewer.
73+
74+ A specific reviewer may be set on a branch. If a specific reviewer
75+ isn't set then any user in the team of the owner of the branch is
76+ considered a reviewer.
77+ """
78+
79+
80+class WrongBranchMergeProposal(Exception):
81+ """The comment requested is not associated with this merge proposal."""
82+
83+
84
85=== modified file 'lib/lp/code/interfaces/branchmergeproposal.py'
86--- lib/lp/code/interfaces/branchmergeproposal.py 2009-10-23 00:48:47 +0000
87+++ lib/lp/code/interfaces/branchmergeproposal.py 2009-12-07 02:20:33 +0000
88@@ -7,11 +7,7 @@
89
90 __metaclass__ = type
91 __all__ = [
92- 'BadBranchMergeProposalSearchContext',
93- 'BadStateTransition',
94- 'BranchMergeProposalExists',
95 'BRANCH_MERGE_PROPOSAL_FINAL_STATES',
96- 'InvalidBranchMergeProposal',
97 'IBranchMergeProposal',
98 'IBranchMergeProposalGetter',
99 'IBranchMergeProposalJob',
100@@ -20,10 +16,9 @@
101 'ICreateMergeProposalJobSource',
102 'IMergeProposalCreatedJob',
103 'IMergeProposalCreatedJobSource',
104- 'UserNotBranchReviewer',
105- 'WrongBranchMergeProposal',
106 ]
107
108+
109 from lazr.lifecycle.event import ObjectModifiedEvent
110 from zope.event import notify
111 from zope.interface import Attribute, Interface
112@@ -47,38 +42,6 @@
113 REQUEST_USER)
114
115
116-class InvalidBranchMergeProposal(Exception):
117- """Raised during the creation of a new branch merge proposal.
118-
119- The text of the exception is the rule violation.
120- """
121-
122-
123-class BranchMergeProposalExists(InvalidBranchMergeProposal):
124- """Raised if there is already a matching BranchMergeProposal."""
125-
126-
127-class UserNotBranchReviewer(Exception):
128- """The user who attempted to review the merge proposal isn't a reviewer.
129-
130- A specific reviewer may be set on a branch. If a specific reviewer
131- isn't set then any user in the team of the owner of the branch is
132- considered a reviewer.
133- """
134-
135-
136-class BadStateTransition(Exception):
137- """The user requested a state transition that is not possible."""
138-
139-
140-class WrongBranchMergeProposal(Exception):
141- """The comment requested is not associated with this merge proposal."""
142-
143-
144-class BadBranchMergeProposalSearchContext(Exception):
145- """The context is not valid for a branch merge proposal search."""
146-
147-
148 BRANCH_MERGE_PROPOSAL_FINAL_STATES = (
149 BranchMergeProposalStatus.REJECTED,
150 BranchMergeProposalStatus.MERGED,
151
152=== modified file 'lib/lp/code/mail/codehandler.py'
153--- lib/lp/code/mail/codehandler.py 2009-10-23 19:33:09 +0000
154+++ lib/lp/code/mail/codehandler.py 2009-12-07 02:20:33 +0000
155@@ -36,10 +36,10 @@
156 from canonical.launchpad.webapp.interfaces import ILaunchBag
157 from lazr.uri import URI
158 from lp.code.enums import BranchType, CodeReviewVote
159+from lp.code.errors import BranchMergeProposalExists, UserNotBranchReviewer
160 from lp.code.interfaces.branchlookup import IBranchLookup
161 from lp.code.interfaces.branchmergeproposal import (
162- BranchMergeProposalExists, IBranchMergeProposalGetter,
163- ICreateMergeProposalJobSource, UserNotBranchReviewer)
164+ IBranchMergeProposalGetter, ICreateMergeProposalJobSource)
165 from lp.code.interfaces.branchnamespace import (
166 lookup_branch_namespace, split_unique_name)
167 from lp.code.interfaces.branchtarget import check_default_stacked_on
168
169=== modified file 'lib/lp/code/model/branch.py'
170--- lib/lp/code/model/branch.py 2009-11-26 22:55:06 +0000
171+++ lib/lp/code/model/branch.py 2009-12-07 02:20:34 +0000
172@@ -47,6 +47,8 @@
173 from lp.code.enums import (
174 BranchLifecycleStatus, BranchMergeControlStatus,
175 BranchMergeProposalStatus, BranchType)
176+from lp.code.errors import (
177+ BranchMergeProposalExists, InvalidBranchMergeProposal)
178 from lp.code.mail.branch import send_branch_modified_notifications
179 from lp.code.model.branchmergeproposal import (
180 BranchMergeProposal, BranchMergeProposalGetter)
181@@ -63,8 +65,7 @@
182 from lp.code.interfaces.branchcollection import IAllBranches
183 from lp.code.interfaces.branchlookup import IBranchLookup
184 from lp.code.interfaces.branchmergeproposal import (
185- BRANCH_MERGE_PROPOSAL_FINAL_STATES, BranchMergeProposalExists,
186- InvalidBranchMergeProposal)
187+ BRANCH_MERGE_PROPOSAL_FINAL_STATES)
188 from lp.code.interfaces.branchnamespace import IBranchNamespacePolicy
189 from lp.code.interfaces.branchpuller import IBranchPuller
190 from lp.code.interfaces.branchtarget import IBranchTarget
191
192=== modified file 'lib/lp/code/model/branchmergeproposal.py'
193--- lib/lp/code/model/branchmergeproposal.py 2009-12-07 02:20:32 +0000
194+++ lib/lp/code/model/branchmergeproposal.py 2009-12-07 02:20:34 +0000
195@@ -30,6 +30,9 @@
196 from canonical.database.sqlbase import quote, SQLBase, sqlvalues
197
198 from lp.code.enums import BranchMergeProposalStatus, CodeReviewVote
199+from lp.code.errors import (
200+ BadBranchMergeProposalSearchContext, BadStateTransition,
201+ UserNotBranchReviewer, WrongBranchMergeProposal)
202 from lp.code.model.branchrevision import BranchRevision
203 from lp.code.model.codereviewcomment import CodeReviewComment
204 from lp.code.model.codereviewvote import (
205@@ -42,10 +45,8 @@
206 from lp.code.interfaces.branch import IBranchNavigationMenu
207 from lp.code.interfaces.branchcollection import IAllBranches
208 from lp.code.interfaces.branchmergeproposal import (
209- BadBranchMergeProposalSearchContext, BadStateTransition,
210 BRANCH_MERGE_PROPOSAL_FINAL_STATES as FINAL_STATES,
211- IBranchMergeProposal, IBranchMergeProposalGetter, UserNotBranchReviewer,
212- WrongBranchMergeProposal)
213+ IBranchMergeProposal, IBranchMergeProposalGetter)
214 from lp.code.interfaces.branchtarget import IHasBranchTarget
215 from lp.registry.interfaces.person import IPerson
216 from lp.registry.interfaces.product import IProduct
217
218=== modified file 'lib/lp/code/model/tests/test_branch.py'
219--- lib/lp/code/model/tests/test_branch.py 2009-11-25 23:24:58 +0000
220+++ lib/lp/code/model/tests/test_branch.py 2009-12-07 02:20:34 +0000
221@@ -37,6 +37,7 @@
222 from lp.code.enums import (
223 BranchLifecycleStatus, BranchSubscriptionNotificationLevel, BranchType,
224 BranchVisibilityRule, CodeReviewNotificationLevel)
225+from lp.code.errors import InvalidBranchMergeProposal
226 from lp.code.interfaces.branch import (
227 BranchCannotBePrivate, BranchCannotBePublic,
228 BranchCreatorNotMemberOfOwnerTeam, BranchCreatorNotOwner,
229@@ -45,8 +46,7 @@
230 from lp.code.interfaces.branchlookup import IBranchLookup
231 from lp.code.interfaces.branchnamespace import IBranchNamespaceSet
232 from lp.code.interfaces.branchmergeproposal import (
233- BRANCH_MERGE_PROPOSAL_FINAL_STATES as FINAL_STATES,
234- InvalidBranchMergeProposal)
235+ BRANCH_MERGE_PROPOSAL_FINAL_STATES as FINAL_STATES)
236 from lp.code.interfaces.linkedbranch import ICanHasLinkedBranch
237 from lp.code.interfaces.seriessourcepackagebranch import (
238 IFindOfficialBranchLinks)
239
240=== modified file 'lib/lp/code/model/tests/test_branchmergeproposals.py'
241--- lib/lp/code/model/tests/test_branchmergeproposals.py 2009-12-07 02:20:32 +0000
242+++ lib/lp/code/model/tests/test_branchmergeproposals.py 2009-12-07 02:20:34 +0000
243@@ -26,6 +26,8 @@
244 from canonical.launchpad.interfaces import IPrivacy
245 from canonical.launchpad.interfaces.message import IMessageJob
246 from canonical.launchpad.webapp.testing import verifyObject
247+from lp.code.errors import (
248+ BadStateTransition, WrongBranchMergeProposal)
249 from lp.code.event.branchmergeproposal import (
250 NewBranchMergeProposalEvent, NewCodeReviewCommentEvent,
251 ReviewerNominatedEvent)
252@@ -36,11 +38,10 @@
253 BranchType, CodeReviewNotificationLevel, CodeReviewVote,
254 BranchVisibilityRule)
255 from lp.code.interfaces.branchmergeproposal import (
256- BadStateTransition,
257 BRANCH_MERGE_PROPOSAL_FINAL_STATES as FINAL_STATES,
258 IBranchMergeProposal, IBranchMergeProposalGetter, IBranchMergeProposalJob,
259 ICreateMergeProposalJob, ICreateMergeProposalJobSource,
260- IMergeProposalCreatedJob, notify_modified, WrongBranchMergeProposal)
261+ IMergeProposalCreatedJob, notify_modified)
262 from lp.code.model.branchmergeproposaljob import (
263 BranchMergeProposalJob, BranchMergeProposalJobType,
264 CreateMergeProposalJob, MergeProposalCreatedJob, UpdatePreviewDiffJob)

Subscribers

People subscribed via source and target branches

to status/vote changes: