Merge lp:~thumper/launchpad/move-branch-errors into lp:launchpad

Proposed by Tim Penhey
Status: Merged
Approved by: Tim Penhey
Approved revision: no longer in the source branch.
Merged at revision: 11286
Proposed branch: lp:~thumper/launchpad/move-branch-errors
Merge into: lp:launchpad
Diff against target: 305 lines (+60/-63)
11 files modified
lib/canonical/launchpad/browser/launchpad.py (+2/-3)
lib/lp/code/errors.py (+36/-3)
lib/lp/code/interfaces/branchnamespace.py (+0/-14)
lib/lp/code/interfaces/linkedbranch.py (+2/-19)
lib/lp/code/model/branchlookup.py (+4/-5)
lib/lp/code/model/branchnamespace.py (+2/-2)
lib/lp/code/model/tests/test_branchlookup.py (+4/-5)
lib/lp/code/model/tests/test_branchnamespace.py (+2/-2)
lib/lp/code/xmlrpc/branch.py (+3/-5)
lib/lp/code/xmlrpc/codehosting.py (+3/-3)
lib/lp/registry/browser/person.py (+2/-2)
To merge this branch: bzr merge lp:~thumper/launchpad/move-branch-errors
Reviewer Review Type Date Requested Status
Michael Hudson-Doyle Approve
Review via email: mp+31602@code.launchpad.net

Commit message

Move some more code errors into lp.code.errors.

Description of the change

Some more simple error moving.

To post a comment you must log in.
Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Assuming make lint is more or less happy, this looks fine!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/canonical/launchpad/browser/launchpad.py'
2--- lib/canonical/launchpad/browser/launchpad.py 2010-08-02 01:37:09 +0000
3+++ lib/canonical/launchpad/browser/launchpad.py 2010-08-03 04:01:43 +0000
4@@ -80,12 +80,11 @@
5 from lp.bugs.interfaces.bug import IBugSet
6 from lp.bugs.interfaces.malone import IMaloneApplication
7 from lp.buildmaster.interfaces.builder import IBuilderSet
8+from lp.code.errors import (
9+ CannotHaveLinkedBranch, InvalidNamespace, NoLinkedBranch)
10 from lp.code.interfaces.branch import IBranchSet
11 from lp.code.interfaces.branchlookup import IBranchLookup
12-from lp.code.interfaces.branchnamespace import InvalidNamespace
13 from lp.code.interfaces.codeimport import ICodeImportSet
14-from lp.code.interfaces.linkedbranch import (
15- CannotHaveLinkedBranch, NoLinkedBranch)
16 from lp.hardwaredb.interfaces.hwdb import IHWDBApplication
17 from lp.registry.interfaces.codeofconduct import ICodeOfConductSet
18 from lp.registry.interfaces.distribution import IDistributionSet
19
20=== modified file 'lib/lp/code/errors.py'
21--- lib/lp/code/errors.py 2010-08-02 02:51:42 +0000
22+++ lib/lp/code/errors.py 2010-08-03 04:01:43 +0000
23@@ -20,12 +20,15 @@
24 'BuildNotAllowedForDistro',
25 'BranchMergeProposalExists',
26 'CannotDeleteBranch',
27+ 'CannotHaveLinkedBranch',
28 'CodeImportAlreadyRequested',
29 'CodeImportAlreadyRunning',
30 'CodeImportNotInReviewedState',
31 'ClaimReviewFailed',
32 'ForbiddenInstruction',
33 'InvalidBranchMergeProposal',
34+ 'InvalidNamespace',
35+ 'NoLinkedBranch',
36 'NoSuchBranch',
37 'PrivateBranchRecipe',
38 'ReviewNotPending',
39@@ -131,10 +134,13 @@
40 """The branch cannot be made private."""
41
42
43-class NoSuchBranch(NameLookupFailed):
44- """Raised when we try to load a branch that does not exist."""
45+class CannotHaveLinkedBranch(Exception):
46+ """Raised when we try to get the linked branch for a thing that can't."""
47
48- _message_prefix = "No such branch"
49+ def __init__(self, component):
50+ self.component = component
51+ Exception.__init__(
52+ self, "%r cannot have linked branches." % (component,))
53
54
55 class ClaimReviewFailed(Exception):
56@@ -154,6 +160,33 @@
57 webservice_error(400) #Bad request.
58
59
60+class InvalidNamespace(Exception):
61+ """Raised when someone tries to lookup a namespace with a bad name.
62+
63+ By 'bad', we mean that the name is unparseable. It might be too short, too
64+ long or malformed in some other way.
65+ """
66+
67+ def __init__(self, name):
68+ self.name = name
69+ Exception.__init__(
70+ self, "Cannot understand namespace name: '%s'" % (name,))
71+
72+
73+class NoLinkedBranch(Exception):
74+ """Raised when there's no linked branch for a thing."""
75+
76+ def __init__(self, component):
77+ self.component = component
78+ Exception.__init__(self, "%r has no linked branch." % (component,))
79+
80+
81+class NoSuchBranch(NameLookupFailed):
82+ """Raised when we try to load a branch that does not exist."""
83+
84+ _message_prefix = "No such branch"
85+
86+
87 class PrivateBranchRecipe(Exception):
88
89 def __init__(self, branch):
90
91=== modified file 'lib/lp/code/interfaces/branchnamespace.py'
92--- lib/lp/code/interfaces/branchnamespace.py 2009-08-13 15:12:16 +0000
93+++ lib/lp/code/interfaces/branchnamespace.py 2010-08-03 04:01:43 +0000
94@@ -11,7 +11,6 @@
95 'IBranchNamespace',
96 'IBranchNamespacePolicy',
97 'IBranchNamespaceSet',
98- 'InvalidNamespace',
99 'lookup_branch_namespace',
100 'split_unique_name',
101 ]
102@@ -281,19 +280,6 @@
103 """
104
105
106-class InvalidNamespace(Exception):
107- """Raised when someone tries to lookup a namespace with a bad name.
108-
109- By 'bad', we mean that the name is unparseable. It might be too short, too
110- long or malformed in some other way.
111- """
112-
113- def __init__(self, name):
114- self.name = name
115- Exception.__init__(
116- self, "Cannot understand namespace name: '%s'" % (name,))
117-
118-
119 def get_branch_namespace(person, product=None, distroseries=None,
120 sourcepackagename=None):
121 return getUtility(IBranchNamespaceSet).get(
122
123=== modified file 'lib/lp/code/interfaces/linkedbranch.py'
124--- lib/lp/code/interfaces/linkedbranch.py 2010-04-07 20:43:03 +0000
125+++ lib/lp/code/interfaces/linkedbranch.py 2010-08-03 04:01:43 +0000
126@@ -12,15 +12,15 @@
127
128 __metaclass__ = type
129 __all__ = [
130- 'CannotHaveLinkedBranch',
131 'get_linked_branch',
132 'ICanHasLinkedBranch',
133- 'NoLinkedBranch',
134 ]
135
136 from zope.interface import Attribute, Interface
137 from zope.security.proxy import isinstance as zope_isinstance
138
139+from lp.code.errors import CannotHaveLinkedBranch, NoLinkedBranch
140+
141
142 class ICanHasLinkedBranch(Interface):
143 """Something that has a linked branch."""
144@@ -41,23 +41,6 @@
145 """
146
147
148-class CannotHaveLinkedBranch(Exception):
149- """Raised when we try to get the linked branch for a thing that can't."""
150-
151- def __init__(self, component):
152- self.component = component
153- Exception.__init__(
154- self, "%r cannot have linked branches." % (component,))
155-
156-
157-class NoLinkedBranch(Exception):
158- """Raised when there's no linked branch for a thing."""
159-
160- def __init__(self, component):
161- self.component = component
162- Exception.__init__(self, "%r has no linked branch." % (component,))
163-
164-
165 def get_linked_branch(provided):
166 """Get the linked branch for 'provided', whatever that is.
167
168
169=== modified file 'lib/lp/code/model/branchlookup.py'
170--- lib/lp/code/model/branchlookup.py 2010-08-02 02:36:32 +0000
171+++ lib/lp/code/model/branchlookup.py 2010-08-03 04:01:43 +0000
172@@ -21,13 +21,12 @@
173 from lp.registry.model.person import Person
174 from lp.registry.model.product import Product
175 from lp.registry.model.sourcepackagename import SourcePackageName
176-from lp.code.errors import NoSuchBranch
177+from lp.code.errors import (
178+ CannotHaveLinkedBranch, InvalidNamespace, NoLinkedBranch, NoSuchBranch)
179 from lp.code.interfaces.branchlookup import (
180 IBranchLookup, ILinkedBranchTraversable, ILinkedBranchTraverser)
181-from lp.code.interfaces.branchnamespace import (
182- IBranchNamespaceSet, InvalidNamespace)
183-from lp.code.interfaces.linkedbranch import (
184- CannotHaveLinkedBranch, get_linked_branch, NoLinkedBranch)
185+from lp.code.interfaces.branchnamespace import IBranchNamespaceSet
186+from lp.code.interfaces.linkedbranch import get_linked_branch
187 from lp.registry.interfaces.distribution import IDistribution
188 from lp.registry.interfaces.distroseries import (
189 IDistroSeries, IDistroSeriesSet, NoSuchDistroSeries)
190
191=== modified file 'lib/lp/code/model/branchnamespace.py'
192--- lib/lp/code/model/branchnamespace.py 2010-08-02 02:36:32 +0000
193+++ lib/lp/code/model/branchnamespace.py 2010-08-03 04:01:43 +0000
194@@ -28,11 +28,11 @@
195 BranchVisibilityRule, CodeReviewNotificationLevel)
196 from lp.code.errors import (
197 BranchCreationForbidden, BranchCreatorNotMemberOfOwnerTeam,
198- BranchCreatorNotOwner, BranchExists, NoSuchBranch)
199+ BranchCreatorNotOwner, BranchExists, InvalidNamespace, NoSuchBranch)
200 from lp.code.interfaces.branch import (
201 IBranch, user_has_special_branch_access)
202 from lp.code.interfaces.branchnamespace import (
203- IBranchNamespace, IBranchNamespacePolicy, InvalidNamespace)
204+ IBranchNamespace, IBranchNamespacePolicy)
205 from lp.code.interfaces.branchtarget import IBranchTarget
206 from lp.code.model.branch import Branch
207 from lp.registry.interfaces.distribution import (
208
209=== modified file 'lib/lp/code/model/tests/test_branchlookup.py'
210--- lib/lp/code/model/tests/test_branchlookup.py 2010-08-02 02:36:32 +0000
211+++ lib/lp/code/model/tests/test_branchlookup.py 2010-08-03 04:01:43 +0000
212@@ -13,13 +13,12 @@
213 from zope.security.proxy import removeSecurityProxy
214
215 from canonical.config import config
216-from lp.code.errors import NoSuchBranch
217+from lp.code.errors import (
218+ CannotHaveLinkedBranch, InvalidNamespace, NoLinkedBranch, NoSuchBranch)
219 from lp.code.interfaces.branchlookup import (
220 IBranchLookup, ILinkedBranchTraverser)
221-from lp.code.interfaces.branchnamespace import (
222- get_branch_namespace, InvalidNamespace)
223-from lp.code.interfaces.linkedbranch import (
224- CannotHaveLinkedBranch, ICanHasLinkedBranch, NoLinkedBranch)
225+from lp.code.interfaces.branchnamespace import get_branch_namespace
226+from lp.code.interfaces.linkedbranch import ICanHasLinkedBranch
227 from lp.registry.interfaces.distroseries import NoSuchDistroSeries
228 from canonical.launchpad.interfaces.launchpad import ILaunchpadCelebrities
229 from lp.registry.interfaces.person import NoSuchPerson
230
231=== modified file 'lib/lp/code/model/tests/test_branchnamespace.py'
232--- lib/lp/code/model/tests/test_branchnamespace.py 2010-08-02 02:36:32 +0000
233+++ lib/lp/code/model/tests/test_branchnamespace.py 2010-08-03 04:01:43 +0000
234@@ -21,10 +21,10 @@
235 BranchLifecycleStatus, BranchType, BranchVisibilityRule)
236 from lp.code.errors import (
237 BranchCreationForbidden, BranchCreatorNotMemberOfOwnerTeam,
238- BranchCreatorNotOwner, BranchExists, NoSuchBranch)
239+ BranchCreatorNotOwner, BranchExists, InvalidNamespace, NoSuchBranch)
240 from lp.code.interfaces.branchnamespace import (
241 get_branch_namespace, IBranchNamespacePolicy, IBranchNamespace,
242- IBranchNamespaceSet, lookup_branch_namespace, InvalidNamespace)
243+ IBranchNamespaceSet, lookup_branch_namespace)
244 from lp.code.interfaces.branchtarget import IBranchTarget
245 from lp.registry.interfaces.distribution import NoSuchDistribution
246 from lp.registry.interfaces.distroseries import NoSuchDistroSeries
247
248=== modified file 'lib/lp/code/xmlrpc/branch.py'
249--- lib/lp/code/xmlrpc/branch.py 2010-08-02 02:51:42 +0000
250+++ lib/lp/code/xmlrpc/branch.py 2010-08-03 04:01:43 +0000
251@@ -23,15 +23,13 @@
252 from canonical.launchpad.webapp.interfaces import ILaunchBag
253 from lp.code.enums import BranchType
254 from lp.code.errors import (
255- BranchCreationException, BranchCreationForbidden, NoSuchBranch)
256+ BranchCreationException, BranchCreationForbidden, CannotHaveLinkedBranch,
257+ InvalidNamespace, NoLinkedBranch, NoSuchBranch)
258 from lp.code.interfaces.branch import IBranch
259 from lp.registry.interfaces.person import IPersonSet
260 from lp.registry.interfaces.product import IProductSet
261 from lp.code.interfaces.branchlookup import IBranchLookup
262-from lp.code.interfaces.branchnamespace import (
263- get_branch_namespace, InvalidNamespace)
264-from lp.code.interfaces.linkedbranch import (
265- CannotHaveLinkedBranch, NoLinkedBranch)
266+from lp.code.interfaces.branchnamespace import get_branch_namespace
267 from lp.registry.interfaces.distroseries import NoSuchDistroSeries
268 from lp.registry.interfaces.person import NoSuchPerson
269 from lp.registry.interfaces.product import (
270
271=== modified file 'lib/lp/code/xmlrpc/codehosting.py'
272--- lib/lp/code/xmlrpc/codehosting.py 2010-08-02 02:51:42 +0000
273+++ lib/lp/code/xmlrpc/codehosting.py 2010-08-03 04:01:43 +0000
274@@ -30,13 +30,13 @@
275 from canonical.launchpad.xmlrpc.helpers import return_fault
276
277 from lp.app.errors import NameLookupFailed, NotFoundError
278-from lp.code.errors import UnknownBranchTypeError
279 from lp.code.bzr import BranchFormat, ControlFormat, RepositoryFormat
280 from lp.code.enums import BranchType
281-from lp.code.errors import BranchCreationException
282+from lp.code.errors import (
283+ BranchCreationException, InvalidNamespace, UnknownBranchTypeError)
284 from lp.code.interfaces.branchlookup import IBranchLookup
285 from lp.code.interfaces.branchnamespace import (
286- InvalidNamespace, lookup_branch_namespace, split_unique_name)
287+ lookup_branch_namespace, split_unique_name)
288 from lp.code.interfaces import branchpuller
289 from lp.code.interfaces.codehosting import (
290 BRANCH_TRANSPORT, CONTROL_TRANSPORT, ICodehostingAPI, LAUNCHPAD_ANONYMOUS,
291
292=== modified file 'lib/lp/registry/browser/person.py'
293--- lib/lp/registry/browser/person.py 2010-08-02 02:13:52 +0000
294+++ lib/lp/registry/browser/person.py 2010-08-03 04:01:43 +0000
295@@ -171,8 +171,8 @@
296 DAYS_BEFORE_EXPIRATION_WARNING_IS_SENT, ITeamMembership,
297 ITeamMembershipSet, TeamMembershipStatus)
298 from lp.registry.interfaces.wikiname import IWikiNameSet
299-from lp.code.interfaces.branchnamespace import (
300- IBranchNamespaceSet, InvalidNamespace)
301+from lp.code.errors import InvalidNamespace
302+from lp.code.interfaces.branchnamespace import IBranchNamespaceSet
303 from lp.bugs.interfaces.bugtask import IBugTaskSet
304 from lp.buildmaster.interfaces.buildbase import BuildStatus
305 from lp.soyuz.interfaces.binarypackagebuild import IBinaryPackageBuildSet