launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #25682
[Merge] ~cjwatson/launchpad:tidy-bzr-code into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:tidy-bzr-code into launchpad:master.
Commit message:
Move a few bzr helpers closer to their sole call sites
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/393822
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:tidy-bzr-code into launchpad:master.
diff --git a/lib/lp/code/scripts/tests/test_reclaim_branch_space.py b/lib/lp/code/scripts/tests/test_reclaim_branch_space.py
index b9e18d7..091b804 100644
--- a/lib/lp/code/scripts/tests/test_reclaim_branch_space.py
+++ b/lib/lp/code/scripts/tests/test_reclaim_branch_space.py
@@ -7,12 +7,14 @@ import datetime
import os
import shutil
+from breezy.transport import get_transport
import transaction
from lp.code.model.branchjob import (
BranchJob,
BranchJobType,
)
+from lp.codehosting.vfs import branch_id_to_path
from lp.services.config import config
from lp.services.database.interfaces import IStore
from lp.services.scripts.tests import run_script
@@ -24,6 +26,20 @@ class TestReclaimBranchSpaceScript(TestCaseWithFactory):
layer = ZopelessAppServerLayer
+ @staticmethod
+ def getBranchPath(branch, base):
+ """Return the path of the branch in the mirrored area.
+
+ This always uses the configured mirrored area, ignoring whatever
+ server might be providing lp-mirrored: urls.
+ """
+ # XXX gary 2009-5-28 bug 381325
+ # This is a work-around for some failures on PQM, arguably caused by
+ # relying on test set-up that is happening in the Makefile rather than
+ # the actual test set-up.
+ get_transport(base).create_prefix()
+ return os.path.join(base, branch_id_to_path(branch.id))
+
def test_reclaimbranchspace_script(self):
# When the reclaimbranchspace script is run, it removes from the file
# system any branches that were deleted from the database more than a
diff --git a/lib/lp/codehosting/tests/helpers.py b/lib/lp/codehosting/tests/helpers.py
index 143dbbd..295acaa 100644
--- a/lib/lp/codehosting/tests/helpers.py
+++ b/lib/lp/codehosting/tests/helpers.py
@@ -11,7 +11,6 @@ __all__ = [
'create_branch_with_one_revision',
'force_stacked_on_url',
'LoomTestMixin',
- 'make_bazaar_branch_and_tree',
'TestResultWrapper',
]
@@ -25,9 +24,6 @@ from breezy.tests import (
)
from testtools.twistedsupport import AsynchronousDeferredRunTest
-from lp.code.enums import BranchType
-from lp.codehosting.vfs import branch_id_to_path
-from lp.services.config import config
from lp.testing import TestCase
@@ -88,17 +84,6 @@ class LoomTestMixin:
return loom_tree
-def make_bazaar_branch_and_tree(db_branch):
- """Make a dummy Bazaar branch and working tree from a database Branch."""
- assert db_branch.branch_type == BranchType.HOSTED, (
- "Can only create branches for HOSTED branches: %r"
- % db_branch)
- branch_dir = os.path.join(
- config.codehosting.mirrored_branches_root,
- branch_id_to_path(db_branch.id))
- return create_branch_with_one_revision(branch_dir)
-
-
def create_branch_with_one_revision(branch_dir, format=None):
"""Create a dummy Bazaar branch at the given directory."""
# XXX cjwatson 2019-06-13: This still uses bzrlib until such time as the
diff --git a/lib/lp/testing/__init__.py b/lib/lp/testing/__init__.py
index 2b4882b..8fb58eb 100644
--- a/lib/lp/testing/__init__.py
+++ b/lib/lp/testing/__init__.py
@@ -85,7 +85,6 @@ from breezy.controldir import (
ControlDir,
format_registry,
)
-from breezy.transport import get_transport
import fixtures
from lazr.restful.testing.tales import test_tales
from lazr.restful.testing.webservice import FakeRequest
@@ -126,10 +125,7 @@ from zope.security.proxy import (
from lp.app.interfaces.launchpad import ILaunchpadCelebrities
from lp.app.interfaces.security import IAuthorization
-from lp.codehosting.vfs import (
- branch_id_to_path,
- get_rw_server,
- )
+from lp.codehosting.vfs import get_rw_server
from lp.registry.interfaces.packaging import IPackagingUtil
from lp.services import features
from lp.services.config import config
@@ -933,20 +929,6 @@ class TestCaseWithFactory(TestCase):
naked_branch.last_scanned_id = bzr_branch.last_revision()
return bzr_branch
- @staticmethod
- def getBranchPath(branch, base):
- """Return the path of the branch in the mirrored area.
-
- This always uses the configured mirrored area, ignoring whatever
- server might be providing lp-mirrored: urls.
- """
- # XXX gary 2009-5-28 bug 381325
- # This is a work-around for some failures on PQM, arguably caused by
- # relying on test set-up that is happening in the Makefile rather than
- # the actual test set-up.
- get_transport(base).create_prefix()
- return os.path.join(base, branch_id_to_path(branch.id))
-
def useTempBzrHome(self):
self.useTempDir()
# Avoid leaking local user configuration into tests.
diff --git a/utilities/make-dummy-hosted-branches b/utilities/make-dummy-hosted-branches
index cd2c650..2b777a0 100755
--- a/utilities/make-dummy-hosted-branches
+++ b/utilities/make-dummy-hosted-branches
@@ -25,16 +25,27 @@ import sys
import tempfile
import transaction
-from zope.component import getUtility
from lp.code.enums import BranchType
from lp.code.model.branch import Branch
-from lp.codehosting.tests.helpers import make_bazaar_branch_and_tree
+from lp.codehosting.tests.helpers import create_branch_with_one_revision
+from lp.codehosting.vfs import branch_id_to_path
from lp.services.config import config
from lp.services.database.sqlbase import sqlvalues
from lp.services.scripts import execute_zcml_for_scripts
+def make_bazaar_branch_and_tree(db_branch):
+ """Make a dummy Bazaar branch and working tree from a database Branch."""
+ assert db_branch.branch_type == BranchType.HOSTED, (
+ "Can only create branches for HOSTED branches: %r"
+ % db_branch)
+ branch_dir = os.path.join(
+ config.codehosting.mirrored_branches_root,
+ branch_id_to_path(db_branch.id))
+ return create_branch_with_one_revision(branch_dir)
+
+
def main(argv):
os.environ['BZR_HOME'] = tempfile.mkdtemp()
if os.path.exists(config.codehosting.mirrored_branches_root):