launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #30687
[Merge] ~cjwatson/launchpad:branch-hosting-import-policy into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:branch-hosting-import-policy into launchpad:master.
Commit message:
Fix import policy violation with InvalidRevisionException
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/455249
I noticed this in test output:
There were 1 imports of names not appearing in the __all__.
You should not import InvalidRevisionException from lp.code.model.branchhosting:
lp.snappy.model.snap
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:branch-hosting-import-policy into launchpad:master.
diff --git a/lib/lp/code/interfaces/branchhosting.py b/lib/lp/code/interfaces/branchhosting.py
index 41b8926..54df027 100644
--- a/lib/lp/code/interfaces/branchhosting.py
+++ b/lib/lp/code/interfaces/branchhosting.py
@@ -5,11 +5,16 @@
__all__ = [
"IBranchHostingClient",
+ "InvalidRevisionException",
]
from zope.interface import Interface
+class InvalidRevisionException(Exception):
+ """An exception thrown when a revision ID is not valid"""
+
+
class IBranchHostingClient(Interface):
"""Interface for the internal API provided by Loggerhead."""
diff --git a/lib/lp/code/model/branchhosting.py b/lib/lp/code/model/branchhosting.py
index 3be5857..06629b3 100644
--- a/lib/lp/code/model/branchhosting.py
+++ b/lib/lp/code/model/branchhosting.py
@@ -16,7 +16,10 @@ from lazr.restful.utils import get_current_browser_request
from zope.interface import implementer
from lp.code.errors import BranchFileNotFound, BranchHostingFault
-from lp.code.interfaces.branchhosting import IBranchHostingClient
+from lp.code.interfaces.branchhosting import (
+ IBranchHostingClient,
+ InvalidRevisionException,
+)
from lp.code.interfaces.codehosting import BRANCH_ID_ALIAS_PREFIX
from lp.services.config import config
from lp.services.timeline.requesttimeline import get_request_timeline
@@ -31,10 +34,6 @@ class RequestExceptionWrapper(requests.RequestException):
"""A non-requests exception that occurred during a request."""
-class InvalidRevisionException(Exception):
- """An exception thrown when a revision ID is not valid"""
-
-
@implementer(IBranchHostingClient)
class BranchHostingClient:
"""A client for the Bazaar Loggerhead API."""
diff --git a/lib/lp/code/model/tests/test_branchhosting.py b/lib/lp/code/model/tests/test_branchhosting.py
index 76e7aa2..b745cde 100644
--- a/lib/lp/code/model/tests/test_branchhosting.py
+++ b/lib/lp/code/model/tests/test_branchhosting.py
@@ -18,8 +18,10 @@ from zope.interface import implementer
from zope.security.proxy import removeSecurityProxy
from lp.code.errors import BranchFileNotFound, BranchHostingFault
-from lp.code.interfaces.branchhosting import IBranchHostingClient
-from lp.code.model.branchhosting import InvalidRevisionException
+from lp.code.interfaces.branchhosting import (
+ IBranchHostingClient,
+ InvalidRevisionException,
+)
from lp.services.job.interfaces.job import IRunnableJob, JobStatus
from lp.services.job.model.job import Job
from lp.services.job.runner import BaseRunnableJob, JobRunner
diff --git a/lib/lp/snappy/model/snap.py b/lib/lp/snappy/model/snap.py
index c47ec1e..d5c26e7 100644
--- a/lib/lp/snappy/model/snap.py
+++ b/lib/lp/snappy/model/snap.py
@@ -67,6 +67,7 @@ from lp.code.errors import (
)
from lp.code.interfaces.branch import IBranch
from lp.code.interfaces.branchcollection import IAllBranches, IBranchCollection
+from lp.code.interfaces.branchhosting import InvalidRevisionException
from lp.code.interfaces.gitcollection import (
IAllGitRepositories,
IGitCollection,
@@ -78,7 +79,6 @@ from lp.code.interfaces.gitrepository import (
)
from lp.code.model.branch import Branch
from lp.code.model.branchcollection import GenericBranchCollection
-from lp.code.model.branchhosting import InvalidRevisionException
from lp.code.model.branchnamespace import (
BRANCH_POLICY_ALLOWED_TYPES,
BRANCH_POLICY_REQUIRED_GRANTS,