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
=== modified file 'lib/canonical/launchpad/browser/launchpad.py'
--- lib/canonical/launchpad/browser/launchpad.py 2010-08-02 01:37:09 +0000
+++ lib/canonical/launchpad/browser/launchpad.py 2010-08-03 04:01:43 +0000
@@ -80,12 +80,11 @@
80from lp.bugs.interfaces.bug import IBugSet80from lp.bugs.interfaces.bug import IBugSet
81from lp.bugs.interfaces.malone import IMaloneApplication81from lp.bugs.interfaces.malone import IMaloneApplication
82from lp.buildmaster.interfaces.builder import IBuilderSet82from lp.buildmaster.interfaces.builder import IBuilderSet
83from lp.code.errors import (
84 CannotHaveLinkedBranch, InvalidNamespace, NoLinkedBranch)
83from lp.code.interfaces.branch import IBranchSet85from lp.code.interfaces.branch import IBranchSet
84from lp.code.interfaces.branchlookup import IBranchLookup86from lp.code.interfaces.branchlookup import IBranchLookup
85from lp.code.interfaces.branchnamespace import InvalidNamespace
86from lp.code.interfaces.codeimport import ICodeImportSet87from lp.code.interfaces.codeimport import ICodeImportSet
87from lp.code.interfaces.linkedbranch import (
88 CannotHaveLinkedBranch, NoLinkedBranch)
89from lp.hardwaredb.interfaces.hwdb import IHWDBApplication88from lp.hardwaredb.interfaces.hwdb import IHWDBApplication
90from lp.registry.interfaces.codeofconduct import ICodeOfConductSet89from lp.registry.interfaces.codeofconduct import ICodeOfConductSet
91from lp.registry.interfaces.distribution import IDistributionSet90from lp.registry.interfaces.distribution import IDistributionSet
9291
=== modified file 'lib/lp/code/errors.py'
--- lib/lp/code/errors.py 2010-08-02 02:51:42 +0000
+++ lib/lp/code/errors.py 2010-08-03 04:01:43 +0000
@@ -20,12 +20,15 @@
20 'BuildNotAllowedForDistro',20 'BuildNotAllowedForDistro',
21 'BranchMergeProposalExists',21 'BranchMergeProposalExists',
22 'CannotDeleteBranch',22 'CannotDeleteBranch',
23 'CannotHaveLinkedBranch',
23 'CodeImportAlreadyRequested',24 'CodeImportAlreadyRequested',
24 'CodeImportAlreadyRunning',25 'CodeImportAlreadyRunning',
25 'CodeImportNotInReviewedState',26 'CodeImportNotInReviewedState',
26 'ClaimReviewFailed',27 'ClaimReviewFailed',
27 'ForbiddenInstruction',28 'ForbiddenInstruction',
28 'InvalidBranchMergeProposal',29 'InvalidBranchMergeProposal',
30 'InvalidNamespace',
31 'NoLinkedBranch',
29 'NoSuchBranch',32 'NoSuchBranch',
30 'PrivateBranchRecipe',33 'PrivateBranchRecipe',
31 'ReviewNotPending',34 'ReviewNotPending',
@@ -131,10 +134,13 @@
131 """The branch cannot be made private."""134 """The branch cannot be made private."""
132135
133136
134class NoSuchBranch(NameLookupFailed):137class CannotHaveLinkedBranch(Exception):
135 """Raised when we try to load a branch that does not exist."""138 """Raised when we try to get the linked branch for a thing that can't."""
136139
137 _message_prefix = "No such branch"140 def __init__(self, component):
141 self.component = component
142 Exception.__init__(
143 self, "%r cannot have linked branches." % (component,))
138144
139145
140class ClaimReviewFailed(Exception):146class ClaimReviewFailed(Exception):
@@ -154,6 +160,33 @@
154 webservice_error(400) #Bad request.160 webservice_error(400) #Bad request.
155161
156162
163class InvalidNamespace(Exception):
164 """Raised when someone tries to lookup a namespace with a bad name.
165
166 By 'bad', we mean that the name is unparseable. It might be too short, too
167 long or malformed in some other way.
168 """
169
170 def __init__(self, name):
171 self.name = name
172 Exception.__init__(
173 self, "Cannot understand namespace name: '%s'" % (name,))
174
175
176class NoLinkedBranch(Exception):
177 """Raised when there's no linked branch for a thing."""
178
179 def __init__(self, component):
180 self.component = component
181 Exception.__init__(self, "%r has no linked branch." % (component,))
182
183
184class NoSuchBranch(NameLookupFailed):
185 """Raised when we try to load a branch that does not exist."""
186
187 _message_prefix = "No such branch"
188
189
157class PrivateBranchRecipe(Exception):190class PrivateBranchRecipe(Exception):
158191
159 def __init__(self, branch):192 def __init__(self, branch):
160193
=== modified file 'lib/lp/code/interfaces/branchnamespace.py'
--- lib/lp/code/interfaces/branchnamespace.py 2009-08-13 15:12:16 +0000
+++ lib/lp/code/interfaces/branchnamespace.py 2010-08-03 04:01:43 +0000
@@ -11,7 +11,6 @@
11 'IBranchNamespace',11 'IBranchNamespace',
12 'IBranchNamespacePolicy',12 'IBranchNamespacePolicy',
13 'IBranchNamespaceSet',13 'IBranchNamespaceSet',
14 'InvalidNamespace',
15 'lookup_branch_namespace',14 'lookup_branch_namespace',
16 'split_unique_name',15 'split_unique_name',
17 ]16 ]
@@ -281,19 +280,6 @@
281 """280 """
282281
283282
284class InvalidNamespace(Exception):
285 """Raised when someone tries to lookup a namespace with a bad name.
286
287 By 'bad', we mean that the name is unparseable. It might be too short, too
288 long or malformed in some other way.
289 """
290
291 def __init__(self, name):
292 self.name = name
293 Exception.__init__(
294 self, "Cannot understand namespace name: '%s'" % (name,))
295
296
297def get_branch_namespace(person, product=None, distroseries=None,283def get_branch_namespace(person, product=None, distroseries=None,
298 sourcepackagename=None):284 sourcepackagename=None):
299 return getUtility(IBranchNamespaceSet).get(285 return getUtility(IBranchNamespaceSet).get(
300286
=== modified file 'lib/lp/code/interfaces/linkedbranch.py'
--- lib/lp/code/interfaces/linkedbranch.py 2010-04-07 20:43:03 +0000
+++ lib/lp/code/interfaces/linkedbranch.py 2010-08-03 04:01:43 +0000
@@ -12,15 +12,15 @@
1212
13__metaclass__ = type13__metaclass__ = type
14__all__ = [14__all__ = [
15 'CannotHaveLinkedBranch',
16 'get_linked_branch',15 'get_linked_branch',
17 'ICanHasLinkedBranch',16 'ICanHasLinkedBranch',
18 'NoLinkedBranch',
19 ]17 ]
2018
21from zope.interface import Attribute, Interface19from zope.interface import Attribute, Interface
22from zope.security.proxy import isinstance as zope_isinstance20from zope.security.proxy import isinstance as zope_isinstance
2321
22from lp.code.errors import CannotHaveLinkedBranch, NoLinkedBranch
23
2424
25class ICanHasLinkedBranch(Interface):25class ICanHasLinkedBranch(Interface):
26 """Something that has a linked branch."""26 """Something that has a linked branch."""
@@ -41,23 +41,6 @@
41 """41 """
4242
4343
44class CannotHaveLinkedBranch(Exception):
45 """Raised when we try to get the linked branch for a thing that can't."""
46
47 def __init__(self, component):
48 self.component = component
49 Exception.__init__(
50 self, "%r cannot have linked branches." % (component,))
51
52
53class NoLinkedBranch(Exception):
54 """Raised when there's no linked branch for a thing."""
55
56 def __init__(self, component):
57 self.component = component
58 Exception.__init__(self, "%r has no linked branch." % (component,))
59
60
61def get_linked_branch(provided):44def get_linked_branch(provided):
62 """Get the linked branch for 'provided', whatever that is.45 """Get the linked branch for 'provided', whatever that is.
6346
6447
=== modified file 'lib/lp/code/model/branchlookup.py'
--- lib/lp/code/model/branchlookup.py 2010-08-02 02:36:32 +0000
+++ lib/lp/code/model/branchlookup.py 2010-08-03 04:01:43 +0000
@@ -21,13 +21,12 @@
21from lp.registry.model.person import Person21from lp.registry.model.person import Person
22from lp.registry.model.product import Product22from lp.registry.model.product import Product
23from lp.registry.model.sourcepackagename import SourcePackageName23from lp.registry.model.sourcepackagename import SourcePackageName
24from lp.code.errors import NoSuchBranch24from lp.code.errors import (
25 CannotHaveLinkedBranch, InvalidNamespace, NoLinkedBranch, NoSuchBranch)
25from lp.code.interfaces.branchlookup import (26from lp.code.interfaces.branchlookup import (
26 IBranchLookup, ILinkedBranchTraversable, ILinkedBranchTraverser)27 IBranchLookup, ILinkedBranchTraversable, ILinkedBranchTraverser)
27from lp.code.interfaces.branchnamespace import (28from lp.code.interfaces.branchnamespace import IBranchNamespaceSet
28 IBranchNamespaceSet, InvalidNamespace)29from lp.code.interfaces.linkedbranch import get_linked_branch
29from lp.code.interfaces.linkedbranch import (
30 CannotHaveLinkedBranch, get_linked_branch, NoLinkedBranch)
31from lp.registry.interfaces.distribution import IDistribution30from lp.registry.interfaces.distribution import IDistribution
32from lp.registry.interfaces.distroseries import (31from lp.registry.interfaces.distroseries import (
33 IDistroSeries, IDistroSeriesSet, NoSuchDistroSeries)32 IDistroSeries, IDistroSeriesSet, NoSuchDistroSeries)
3433
=== modified file 'lib/lp/code/model/branchnamespace.py'
--- lib/lp/code/model/branchnamespace.py 2010-08-02 02:36:32 +0000
+++ lib/lp/code/model/branchnamespace.py 2010-08-03 04:01:43 +0000
@@ -28,11 +28,11 @@
28 BranchVisibilityRule, CodeReviewNotificationLevel)28 BranchVisibilityRule, CodeReviewNotificationLevel)
29from lp.code.errors import (29from lp.code.errors import (
30 BranchCreationForbidden, BranchCreatorNotMemberOfOwnerTeam,30 BranchCreationForbidden, BranchCreatorNotMemberOfOwnerTeam,
31 BranchCreatorNotOwner, BranchExists, NoSuchBranch)31 BranchCreatorNotOwner, BranchExists, InvalidNamespace, NoSuchBranch)
32from lp.code.interfaces.branch import (32from lp.code.interfaces.branch import (
33 IBranch, user_has_special_branch_access)33 IBranch, user_has_special_branch_access)
34from lp.code.interfaces.branchnamespace import (34from lp.code.interfaces.branchnamespace import (
35 IBranchNamespace, IBranchNamespacePolicy, InvalidNamespace)35 IBranchNamespace, IBranchNamespacePolicy)
36from lp.code.interfaces.branchtarget import IBranchTarget36from lp.code.interfaces.branchtarget import IBranchTarget
37from lp.code.model.branch import Branch37from lp.code.model.branch import Branch
38from lp.registry.interfaces.distribution import (38from lp.registry.interfaces.distribution import (
3939
=== modified file 'lib/lp/code/model/tests/test_branchlookup.py'
--- lib/lp/code/model/tests/test_branchlookup.py 2010-08-02 02:36:32 +0000
+++ lib/lp/code/model/tests/test_branchlookup.py 2010-08-03 04:01:43 +0000
@@ -13,13 +13,12 @@
13from zope.security.proxy import removeSecurityProxy13from zope.security.proxy import removeSecurityProxy
1414
15from canonical.config import config15from canonical.config import config
16from lp.code.errors import NoSuchBranch16from lp.code.errors import (
17 CannotHaveLinkedBranch, InvalidNamespace, NoLinkedBranch, NoSuchBranch)
17from lp.code.interfaces.branchlookup import (18from lp.code.interfaces.branchlookup import (
18 IBranchLookup, ILinkedBranchTraverser)19 IBranchLookup, ILinkedBranchTraverser)
19from lp.code.interfaces.branchnamespace import (20from lp.code.interfaces.branchnamespace import get_branch_namespace
20 get_branch_namespace, InvalidNamespace)21from lp.code.interfaces.linkedbranch import ICanHasLinkedBranch
21from lp.code.interfaces.linkedbranch import (
22 CannotHaveLinkedBranch, ICanHasLinkedBranch, NoLinkedBranch)
23from lp.registry.interfaces.distroseries import NoSuchDistroSeries22from lp.registry.interfaces.distroseries import NoSuchDistroSeries
24from canonical.launchpad.interfaces.launchpad import ILaunchpadCelebrities23from canonical.launchpad.interfaces.launchpad import ILaunchpadCelebrities
25from lp.registry.interfaces.person import NoSuchPerson24from lp.registry.interfaces.person import NoSuchPerson
2625
=== modified file 'lib/lp/code/model/tests/test_branchnamespace.py'
--- lib/lp/code/model/tests/test_branchnamespace.py 2010-08-02 02:36:32 +0000
+++ lib/lp/code/model/tests/test_branchnamespace.py 2010-08-03 04:01:43 +0000
@@ -21,10 +21,10 @@
21 BranchLifecycleStatus, BranchType, BranchVisibilityRule)21 BranchLifecycleStatus, BranchType, BranchVisibilityRule)
22from lp.code.errors import (22from lp.code.errors import (
23 BranchCreationForbidden, BranchCreatorNotMemberOfOwnerTeam,23 BranchCreationForbidden, BranchCreatorNotMemberOfOwnerTeam,
24 BranchCreatorNotOwner, BranchExists, NoSuchBranch)24 BranchCreatorNotOwner, BranchExists, InvalidNamespace, NoSuchBranch)
25from lp.code.interfaces.branchnamespace import (25from lp.code.interfaces.branchnamespace import (
26 get_branch_namespace, IBranchNamespacePolicy, IBranchNamespace,26 get_branch_namespace, IBranchNamespacePolicy, IBranchNamespace,
27 IBranchNamespaceSet, lookup_branch_namespace, InvalidNamespace)27 IBranchNamespaceSet, lookup_branch_namespace)
28from lp.code.interfaces.branchtarget import IBranchTarget28from lp.code.interfaces.branchtarget import IBranchTarget
29from lp.registry.interfaces.distribution import NoSuchDistribution29from lp.registry.interfaces.distribution import NoSuchDistribution
30from lp.registry.interfaces.distroseries import NoSuchDistroSeries30from lp.registry.interfaces.distroseries import NoSuchDistroSeries
3131
=== modified file 'lib/lp/code/xmlrpc/branch.py'
--- lib/lp/code/xmlrpc/branch.py 2010-08-02 02:51:42 +0000
+++ lib/lp/code/xmlrpc/branch.py 2010-08-03 04:01:43 +0000
@@ -23,15 +23,13 @@
23from canonical.launchpad.webapp.interfaces import ILaunchBag23from canonical.launchpad.webapp.interfaces import ILaunchBag
24from lp.code.enums import BranchType24from lp.code.enums import BranchType
25from lp.code.errors import (25from lp.code.errors import (
26 BranchCreationException, BranchCreationForbidden, NoSuchBranch)26 BranchCreationException, BranchCreationForbidden, CannotHaveLinkedBranch,
27 InvalidNamespace, NoLinkedBranch, NoSuchBranch)
27from lp.code.interfaces.branch import IBranch28from lp.code.interfaces.branch import IBranch
28from lp.registry.interfaces.person import IPersonSet29from lp.registry.interfaces.person import IPersonSet
29from lp.registry.interfaces.product import IProductSet30from lp.registry.interfaces.product import IProductSet
30from lp.code.interfaces.branchlookup import IBranchLookup31from lp.code.interfaces.branchlookup import IBranchLookup
31from lp.code.interfaces.branchnamespace import (32from lp.code.interfaces.branchnamespace import get_branch_namespace
32 get_branch_namespace, InvalidNamespace)
33from lp.code.interfaces.linkedbranch import (
34 CannotHaveLinkedBranch, NoLinkedBranch)
35from lp.registry.interfaces.distroseries import NoSuchDistroSeries33from lp.registry.interfaces.distroseries import NoSuchDistroSeries
36from lp.registry.interfaces.person import NoSuchPerson34from lp.registry.interfaces.person import NoSuchPerson
37from lp.registry.interfaces.product import (35from lp.registry.interfaces.product import (
3836
=== modified file 'lib/lp/code/xmlrpc/codehosting.py'
--- lib/lp/code/xmlrpc/codehosting.py 2010-08-02 02:51:42 +0000
+++ lib/lp/code/xmlrpc/codehosting.py 2010-08-03 04:01:43 +0000
@@ -30,13 +30,13 @@
30from canonical.launchpad.xmlrpc.helpers import return_fault30from canonical.launchpad.xmlrpc.helpers import return_fault
3131
32from lp.app.errors import NameLookupFailed, NotFoundError32from lp.app.errors import NameLookupFailed, NotFoundError
33from lp.code.errors import UnknownBranchTypeError
34from lp.code.bzr import BranchFormat, ControlFormat, RepositoryFormat33from lp.code.bzr import BranchFormat, ControlFormat, RepositoryFormat
35from lp.code.enums import BranchType34from lp.code.enums import BranchType
36from lp.code.errors import BranchCreationException35from lp.code.errors import (
36 BranchCreationException, InvalidNamespace, UnknownBranchTypeError)
37from lp.code.interfaces.branchlookup import IBranchLookup37from lp.code.interfaces.branchlookup import IBranchLookup
38from lp.code.interfaces.branchnamespace import (38from lp.code.interfaces.branchnamespace import (
39 InvalidNamespace, lookup_branch_namespace, split_unique_name)39 lookup_branch_namespace, split_unique_name)
40from lp.code.interfaces import branchpuller40from lp.code.interfaces import branchpuller
41from lp.code.interfaces.codehosting import (41from lp.code.interfaces.codehosting import (
42 BRANCH_TRANSPORT, CONTROL_TRANSPORT, ICodehostingAPI, LAUNCHPAD_ANONYMOUS,42 BRANCH_TRANSPORT, CONTROL_TRANSPORT, ICodehostingAPI, LAUNCHPAD_ANONYMOUS,
4343
=== modified file 'lib/lp/registry/browser/person.py'
--- lib/lp/registry/browser/person.py 2010-08-02 02:13:52 +0000
+++ lib/lp/registry/browser/person.py 2010-08-03 04:01:43 +0000
@@ -171,8 +171,8 @@
171 DAYS_BEFORE_EXPIRATION_WARNING_IS_SENT, ITeamMembership,171 DAYS_BEFORE_EXPIRATION_WARNING_IS_SENT, ITeamMembership,
172 ITeamMembershipSet, TeamMembershipStatus)172 ITeamMembershipSet, TeamMembershipStatus)
173from lp.registry.interfaces.wikiname import IWikiNameSet173from lp.registry.interfaces.wikiname import IWikiNameSet
174from lp.code.interfaces.branchnamespace import (174from lp.code.errors import InvalidNamespace
175 IBranchNamespaceSet, InvalidNamespace)175from lp.code.interfaces.branchnamespace import IBranchNamespaceSet
176from lp.bugs.interfaces.bugtask import IBugTaskSet176from lp.bugs.interfaces.bugtask import IBugTaskSet
177from lp.buildmaster.interfaces.buildbase import BuildStatus177from lp.buildmaster.interfaces.buildbase import BuildStatus
178from lp.soyuz.interfaces.binarypackagebuild import IBinaryPackageBuildSet178from lp.soyuz.interfaces.binarypackagebuild import IBinaryPackageBuildSet