Merge lp:~mwhudson/launchpad/no-hosted-area-server-catchup into lp:launchpad/db-devel

Proposed by Michael Hudson-Doyle
Status: Merged
Approved by: Tim Penhey
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~mwhudson/launchpad/no-hosted-area-server-catchup
Merge into: lp:launchpad/db-devel
Prerequisite: lp:~mwhudson/launchpad/no-hosted-area-scanner-tests
Diff against target: 553 lines (+61/-173)
14 files modified
cronscripts/rosetta-branches.py (+2/-2)
cronscripts/sendbranchmail.py (+2/-2)
lib/lp/code/model/directbranchcommit.py (+2/-2)
lib/lp/code/scripts/tests/test_sendbranchmail.py (+3/-3)
lib/lp/codehosting/puller/tests/test_acceptance.py (+12/-19)
lib/lp/codehosting/puller/tests/test_scheduler.py (+7/-5)
lib/lp/codehosting/vfs/__init__.py (+2/-5)
lib/lp/codehosting/vfs/branchfs.py (+2/-47)
lib/lp/codehosting/vfs/tests/test_branchfs.py (+17/-3)
lib/lp/codehosting/vfs/transport.py (+0/-20)
lib/lp/testing/__init__.py (+0/-19)
lib/lp/testing/factory.py (+2/-1)
lib/lp/translations/tests/test_rosetta_branches_script.py (+2/-2)
scripts/update-stacked-on.py (+8/-43)
To merge this branch: bzr merge lp:~mwhudson/launchpad/no-hosted-area-server-catchup
Reviewer Review Type Date Requested Status
Tim Penhey (community) Approve
Review via email: mp+24098@code.launchpad.net

Description of the change

Hi Tim,

This branch is mostly a cleanup, it removes all uses of get_puller_server or get_scanner_server and replaces them with get_rw_server or get_ro_server as appropriate.

There are also some clean ups and test fixes that really belong in a lower pipe -- I hope you'll forgive me for those.

Cheers,
mwh

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

This is all good.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'cronscripts/rosetta-branches.py'
--- cronscripts/rosetta-branches.py 2010-02-16 15:25:52 +0000
+++ cronscripts/rosetta-branches.py 2010-04-27 02:24:09 +0000
@@ -17,7 +17,7 @@
17from zope.component import getUtility17from zope.component import getUtility
1818
19from canonical.config import config19from canonical.config import config
20from lp.codehosting.vfs.branchfs import get_scanner_server20from lp.codehosting.vfs.branchfs import get_ro_server
21from lp.services.job.runner import JobRunner21from lp.services.job.runner import JobRunner
22from lp.code.interfaces.branchjob import IRosettaUploadJobSource22from lp.code.interfaces.branchjob import IRosettaUploadJobSource
23from lp.services.scripts.base import LaunchpadCronScript23from lp.services.scripts.base import LaunchpadCronScript
@@ -31,7 +31,7 @@
31 globalErrorUtility.configure('rosettabranches')31 globalErrorUtility.configure('rosettabranches')
32 runner = JobRunner.fromReady(32 runner = JobRunner.fromReady(
33 getUtility(IRosettaUploadJobSource), self.logger)33 getUtility(IRosettaUploadJobSource), self.logger)
34 server = get_scanner_server()34 server = get_ro_server()
35 server.start_server()35 server.start_server()
36 try:36 try:
37 runner.runAll()37 runner.runAll()
3838
=== modified file 'cronscripts/sendbranchmail.py'
--- cronscripts/sendbranchmail.py 2010-02-16 15:25:52 +0000
+++ cronscripts/sendbranchmail.py 2010-04-27 02:24:09 +0000
@@ -16,7 +16,7 @@
16from zope.component import getUtility16from zope.component import getUtility
1717
18from canonical.config import config18from canonical.config import config
19from lp.codehosting.vfs import get_scanner_server19from lp.codehosting.vfs import get_ro_server
20from lp.services.job.runner import JobRunner20from lp.services.job.runner import JobRunner
21from lp.code.interfaces.branchjob import (21from lp.code.interfaces.branchjob import (
22 IRevisionMailJobSource, IRevisionsAddedJobSource)22 IRevisionMailJobSource, IRevisionsAddedJobSource)
@@ -32,7 +32,7 @@
32 jobs = list(getUtility(IRevisionMailJobSource).iterReady())32 jobs = list(getUtility(IRevisionMailJobSource).iterReady())
33 jobs.extend(getUtility(IRevisionsAddedJobSource).iterReady())33 jobs.extend(getUtility(IRevisionsAddedJobSource).iterReady())
34 runner = JobRunner(jobs, self.logger)34 runner = JobRunner(jobs, self.logger)
35 server = get_scanner_server()35 server = get_ro_server()
36 server.start_server()36 server.start_server()
37 try:37 try:
38 runner.runAll()38 runner.runAll()
3939
=== modified file 'lib/lp/code/model/directbranchcommit.py'
--- lib/lp/code/model/directbranchcommit.py 2010-04-27 02:24:00 +0000
+++ lib/lp/code/model/directbranchcommit.py 2010-04-27 02:24:09 +0000
@@ -51,9 +51,9 @@
51 """Create context for direct commit to branch.51 """Create context for direct commit to branch.
5252
53 Before constructing a `DirectBranchCommit`, set up a server that53 Before constructing a `DirectBranchCommit`, set up a server that
54 allows write access to lp-hosted:/// URLs:54 allows write access to lp-internal:/// URLs:
5555
56 bzrserver = get_multi_server(write_hosted=True)56 bzrserver = get_rw_server()
57 bzrserver.start_server()57 bzrserver.start_server()
58 try:58 try:
59 branchcommit = DirectBranchCommit(branch)59 branchcommit = DirectBranchCommit(branch)
6060
=== modified file 'lib/lp/code/scripts/tests/test_sendbranchmail.py'
--- lib/lp/code/scripts/tests/test_sendbranchmail.py 2010-04-01 04:37:30 +0000
+++ lib/lp/code/scripts/tests/test_sendbranchmail.py 2010-04-27 02:24:09 +0000
@@ -23,7 +23,7 @@
23 layer = ZopelessAppServerLayer23 layer = ZopelessAppServerLayer
2424
25 def createBranch(self):25 def createBranch(self):
26 branch, tree = self.createMirroredBranchAndTree()26 branch, tree = self.create_branch_and_tree()
27 branch.subscribe(branch.registrant,27 branch.subscribe(branch.registrant,
28 BranchSubscriptionNotificationLevel.FULL,28 BranchSubscriptionNotificationLevel.FULL,
29 BranchSubscriptionDiffSize.WHOLEDIFF,29 BranchSubscriptionDiffSize.WHOLEDIFF,
@@ -36,7 +36,7 @@
3636
37 def test_sendbranchmail(self):37 def test_sendbranchmail(self):
38 """Ensure sendbranchmail runs and sends email."""38 """Ensure sendbranchmail runs and sends email."""
39 self.useTempBzrHome()39 self.useBzrBranches()
40 branch, tree = self.createBranch()40 branch, tree = self.createBranch()
41 RevisionMailJob.create(41 RevisionMailJob.create(
42 branch, 1, 'from@example.org', 'body', True, 'foo')42 branch, 1, 'from@example.org', 'body', True, 'foo')
@@ -68,7 +68,7 @@
6868
69 def test_revision_added_job(self):69 def test_revision_added_job(self):
70 """RevisionsAddedJobs are run by sendbranchmail."""70 """RevisionsAddedJobs are run by sendbranchmail."""
71 self.useTempBzrHome()71 self.useBzrBranches()
72 branch, tree = self.createBranch()72 branch, tree = self.createBranch()
73 tree.bzrdir.root_transport.put_bytes('foo', 'baz')73 tree.bzrdir.root_transport.put_bytes('foo', 'baz')
74 tree.commit('Added foo.', rev_id='rev2')74 tree.commit('Added foo.', rev_id='rev2')
7575
=== modified file 'lib/lp/codehosting/puller/tests/test_acceptance.py'
--- lib/lp/codehosting/puller/tests/test_acceptance.py 2010-04-27 02:24:00 +0000
+++ lib/lp/codehosting/puller/tests/test_acceptance.py 2010-04-27 02:24:09 +0000
@@ -7,22 +7,18 @@
7__all__ = []7__all__ = []
88
99
10import datetime
11import os10import os
12from subprocess import PIPE, Popen11from subprocess import PIPE, Popen
13import unittest12import unittest
1413
15import pytz
1614
17import transaction15import transaction
1816
19from bzrlib.branch import Branch17from bzrlib.branch import Branch
20from bzrlib.bzrdir import BzrDir18from bzrlib.bzrdir import BzrDir
21from bzrlib import errors19from bzrlib import errors
22from bzrlib.transport import get_transport
23from bzrlib.upgrade import upgrade20from bzrlib.upgrade import upgrade
24from bzrlib.urlutils import (21from bzrlib.urlutils import join as urljoin, local_path_from_url
25 join as urljoin, local_path_from_url, local_path_to_url)
26from bzrlib.workingtree import WorkingTree22from bzrlib.workingtree import WorkingTree
2723
28from zope.component import getUtility24from zope.component import getUtility
@@ -30,7 +26,7 @@
3026
31from lp.code.enums import BranchType27from lp.code.enums import BranchType
32from lp.code.interfaces.branchtarget import IBranchTarget28from lp.code.interfaces.branchtarget import IBranchTarget
33from lp.codehosting.vfs import branch_id_to_path, get_lp_server29from lp.codehosting.vfs import get_lp_server
34from lp.codehosting.puller.tests import PullerBranchTestCase30from lp.codehosting.puller.tests import PullerBranchTestCase
35from lp.codehosting.tests.helpers import LoomTestMixin31from lp.codehosting.tests.helpers import LoomTestMixin
36from canonical.config import config32from canonical.config import config
@@ -56,8 +52,7 @@
56 self.makeCleanDirectory(52 self.makeCleanDirectory(
57 local_path_from_url(config.launchpad.bzr_imports_root_url))53 local_path_from_url(config.launchpad.bzr_imports_root_url))
5854
59 def assertMirrored(self, db_branch, source_branch,55 def assertMirrored(self, db_branch, source_branch):
60 accessing_user=None):
61 """Assert that 'db_branch' was mirrored succesfully.56 """Assert that 'db_branch' was mirrored succesfully.
6257
63 This method checks that the fields on db_branch show that the branch58 This method checks that the fields on db_branch show that the branch
@@ -73,8 +68,7 @@
73 supplied create a fresh user for this -- but this won't work for a68 supplied create a fresh user for this -- but this won't work for a
74 private branch.69 private branch.
75 """70 """
76 if accessing_user is None:71 accessing_user = self.factory.makePerson()
77 accessing_user = self.factory.makePerson()
78 transaction.commit()72 transaction.commit()
79 self.assertEqual(None, db_branch.mirror_status_message)73 self.assertEqual(None, db_branch.mirror_status_message)
80 self.assertEqual(74 self.assertEqual(
@@ -219,22 +213,21 @@
219 (defaults to not).213 (defaults to not).
220 :return: `IBranch`.214 :return: `IBranch`.
221 """215 """
222 # Make the branch.216 # Make the branch in the database.
223 product = self.factory.makeProduct()217 product = self.factory.makeProduct()
224 default_branch = self.factory.makeProductBranch(218 default_branch = self.factory.makeProductBranch(
225 product=product, private=private)219 product=product, private=private)
226 default_branch.last_mirrored = datetime.datetime.now(pytz.UTC)220 transaction.commit()
227 # Make it the default stacked-on branch.221 # Create the underlying bzr branch.
222 lp_server = self.getLPServerForUser(default_branch.owner)
223 BzrDir.create_branch_convenience(
224 lp_server.get_url() + default_branch.unique_name)
225 transaction.commit()
226 # Make it the default stacked-on branch for the product.
228 series = removeSecurityProxy(product.development_focus)227 series = removeSecurityProxy(product.development_focus)
229 series.branch = default_branch228 series.branch = default_branch
230 self.assertEqual(229 self.assertEqual(
231 default_branch, IBranchTarget(product).default_stacked_on_branch)230 default_branch, IBranchTarget(product).default_stacked_on_branch)
232 branch_location = urljoin(
233 local_path_to_url(config.codehosting.mirrored_branches_root),
234 branch_id_to_path(default_branch.id))
235 get_transport(branch_location).create_prefix()
236 BzrDir.create_branch_convenience(branch_location)
237 transaction.commit()
238 return default_branch231 return default_branch
239232
240 def test_stack_mirrored_branch(self):233 def test_stack_mirrored_branch(self):
241234
=== modified file 'lib/lp/codehosting/puller/tests/test_scheduler.py'
--- lib/lp/codehosting/puller/tests/test_scheduler.py 2010-04-27 02:24:00 +0000
+++ lib/lp/codehosting/puller/tests/test_scheduler.py 2010-04-27 02:24:09 +0000
@@ -28,6 +28,7 @@
28from canonical.launchpad.webapp import errorlog28from canonical.launchpad.webapp import errorlog
29from canonical.testing import (29from canonical.testing import (
30 reset_logging, TwistedLayer, TwistedAppServerLayer)30 reset_logging, TwistedLayer, TwistedAppServerLayer)
31from lp.code.interfaces.codehosting import LAUNCHPAD_SERVICES
31from lp.codehosting.puller import get_lock_id_for_branch_id, scheduler32from lp.codehosting.puller import get_lock_id_for_branch_id, scheduler
32from lp.codehosting.puller.tests import PullerBranchTestCase33from lp.codehosting.puller.tests import PullerBranchTestCase
33from lp.codehosting.puller.worker import (34from lp.codehosting.puller.worker import (
@@ -454,9 +455,9 @@
454455
455 def checkMirrorCompleted(ignored):456 def checkMirrorCompleted(ignored):
456 self.assertEqual(457 self.assertEqual(
457 [('branchChanged', self.arbitrary_branch_id, stacked_on_url,458 [('branchChanged', LAUNCHPAD_SERVICES,
458 revid_after, control_string, branch_string,459 self.arbitrary_branch_id, stacked_on_url, revid_after,
459 repository_string)],460 control_string, branch_string, repository_string)],
460 self.status_client.calls)461 self.status_client.calls)
461 return deferred.addCallback(checkMirrorCompleted)462 return deferred.addCallback(checkMirrorCompleted)
462463
@@ -680,8 +681,9 @@
680 repository_string = \681 repository_string = \
681 default_format.repository_format.get_format_string()682 default_format.repository_format.get_format_string()
682 self.assertEqual(683 self.assertEqual(
683 [('branchChanged', self.db_branch.id, '', revision_id,684 [('branchChanged', LAUNCHPAD_SERVICES, self.db_branch.id, '',
684 control_string, branch_string, repository_string)],685 revision_id, control_string, branch_string,
686 repository_string)],
685 self.client.calls)687 self.client.calls)
686 return ignored688 return ignored
687 deferred.addCallback(check_authserver_called)689 deferred.addCallback(check_authserver_called)
688690
=== modified file 'lib/lp/codehosting/vfs/__init__.py'
--- lib/lp/codehosting/vfs/__init__.py 2010-04-27 02:24:00 +0000
+++ lib/lp/codehosting/vfs/__init__.py 2010-04-27 02:24:09 +0000
@@ -9,17 +9,14 @@
9 'branch_id_to_path',9 'branch_id_to_path',
10 'BranchFileSystemClient',10 'BranchFileSystemClient',
11 'get_lp_server',11 'get_lp_server',
12 'get_multi_server',
13 'get_ro_server',12 'get_ro_server',
14 'get_rw_server',13 'get_rw_server',
15 'get_scanner_server',
16 'LaunchpadServer',14 'LaunchpadServer',
17 'make_branch_mirrorer',15 'make_branch_mirrorer',
18 ]16 ]
1917
20from lp.codehosting.vfs.branchfs import (18from lp.codehosting.vfs.branchfs import (
21 AsyncLaunchpadTransport, branch_id_to_path, get_lp_server,19 AsyncLaunchpadTransport, LaunchpadServer, branch_id_to_path,
22 get_multi_server, get_ro_server, get_rw_server, get_scanner_server,20 get_lp_server, get_ro_server, get_rw_server, make_branch_mirrorer)
23 LaunchpadServer, make_branch_mirrorer)
24from lp.codehosting.vfs.branchfsclient import (21from lp.codehosting.vfs.branchfsclient import (
25 BlockingProxy,BranchFileSystemClient)22 BlockingProxy,BranchFileSystemClient)
2623
=== modified file 'lib/lp/codehosting/vfs/branchfs.py'
--- lib/lp/codehosting/vfs/branchfs.py 2010-04-27 02:24:00 +0000
+++ lib/lp/codehosting/vfs/branchfs.py 2010-04-27 02:24:09 +0000
@@ -54,10 +54,8 @@
54 'BranchPolicy',54 'BranchPolicy',
55 'DirectDatabaseLaunchpadServer',55 'DirectDatabaseLaunchpadServer',
56 'get_lp_server',56 'get_lp_server',
57 'get_multi_server',
58 'get_ro_server',57 'get_ro_server',
59 'get_rw_server',58 'get_rw_server',
60 'get_scanner_server',
61 'make_branch_mirrorer',59 'make_branch_mirrorer',
62 'LaunchpadInternalServer',60 'LaunchpadInternalServer',
63 'LaunchpadServer',61 'LaunchpadServer',
@@ -88,8 +86,8 @@
88from lp.codehosting.vfs.branchfsclient import (86from lp.codehosting.vfs.branchfsclient import (
89 BlockingProxy, BranchFileSystemClient)87 BlockingProxy, BranchFileSystemClient)
90from lp.codehosting.vfs.transport import (88from lp.codehosting.vfs.transport import (
91 AsyncVirtualServer, AsyncVirtualTransport, _MultiServer,89 AsyncVirtualServer, AsyncVirtualTransport, TranslationError,
92 get_chrooted_transport, get_readonly_transport, TranslationError)90 get_chrooted_transport, get_readonly_transport)
93from canonical.config import config91from canonical.config import config
94from canonical.launchpad.xmlrpc import faults92from canonical.launchpad.xmlrpc import faults
95from lp.code.enums import BranchType93from lp.code.enums import BranchType
@@ -177,7 +175,6 @@
177 return LaunchpadInternalServer(175 return LaunchpadInternalServer(
178 'lp-internal:///', codehosting_endpoint, branch_transport)176 'lp-internal:///', codehosting_endpoint, branch_transport)
179177
180get_scanner_server = get_ro_server
181178
182def get_rw_server(direct_database=False):179def get_rw_server(direct_database=False):
183 """Get a server that can write to the Launchpad branch vfs.180 """Get a server that can write to the Launchpad branch vfs.
@@ -200,48 +197,6 @@
200 'lp-internal:///', codehosting_endpoint, transport)197 'lp-internal:///', codehosting_endpoint, transport)
201198
202199
203def get_multi_server(write_hosted=False, write_mirrored=False,
204 direct_database=False):
205 """Get a server with access to both mirrored and hosted areas.
206
207 The server wraps up two `LaunchpadInternalServer`s or
208 `DirectDatabaseLaunchpadServer`s. One server points to the hosted branch
209 area and the other points to the mirrored area.
210
211 Write permision defaults to False, but can be overridden.
212
213 :param write_hosted: if True, lp-hosted URLs are writeable. Otherwise,
214 they are read-only.
215 :param write_mirrored: if True, lp-mirrored URLs are writeable.
216 Otherwise, they are read-only.
217
218 :param direct_database: if True, use a server implementation that talks
219 directly to the database. If False, the default, use a server
220 implementation that talks to the internal XML-RPC server.
221 """
222 # XXX 2010-04-20, MichaelHudson: this function will disappear in a later
223 # pipe.
224 hosted_transport = get_chrooted_transport(
225 config.codehosting.mirrored_branches_root, mkdir=True)
226 if not write_hosted:
227 hosted_transport = get_readonly_transport(hosted_transport)
228 mirrored_transport = get_chrooted_transport(
229 config.codehosting.mirrored_branches_root, mkdir=True)
230 if not write_mirrored:
231 mirrored_transport = get_readonly_transport(mirrored_transport)
232 if direct_database:
233 make_server = DirectDatabaseLaunchpadServer
234 else:
235 proxy = xmlrpclib.ServerProxy(config.codehosting.codehosting_endpoint)
236 codehosting_endpoint = BlockingProxy(proxy)
237 def make_server(scheme, transport):
238 return LaunchpadInternalServer(
239 scheme, codehosting_endpoint, transport)
240 hosted_server = make_server('lp-hosted:///', hosted_transport)
241 mirrored_server = make_server('lp-mirrored:///', mirrored_transport)
242 return _MultiServer(hosted_server, mirrored_server)
243
244
245class ITransportDispatch(Interface):200class ITransportDispatch(Interface):
246 """Turns descriptions of transports into transports."""201 """Turns descriptions of transports into transports."""
247202
248203
=== modified file 'lib/lp/codehosting/vfs/tests/test_branchfs.py'
--- lib/lp/codehosting/vfs/tests/test_branchfs.py 2010-04-27 02:24:00 +0000
+++ lib/lp/codehosting/vfs/tests/test_branchfs.py 2010-04-27 02:24:09 +0000
@@ -826,11 +826,12 @@
826 self.backing_transport = MemoryTransport()826 self.backing_transport = MemoryTransport()
827 self.disable_directory_isolation()827 self.disable_directory_isolation()
828828
829 def _replacement_branchChanged(self, branch_id, stacked_on_url,829 def _replacement_branchChanged(self, user_id, branch_id, stacked_on_url,
830 last_revision, *format_strings):830 last_revision, *format_strings):
831 self._branch_changed_log.append(dict(831 self._branch_changed_log.append(dict(
832 branch_id=branch_id, stacked_on_url=stacked_on_url,832 user_id=user_id, branch_id=branch_id,
833 last_revision=last_revision, format_strings=format_strings))833 stacked_on_url=stacked_on_url, last_revision=last_revision,
834 format_strings=format_strings))
834835
835 def get_server(self):836 def get_server(self):
836 if self._server is None:837 if self._server is None:
@@ -862,6 +863,19 @@
862 branch.unlock()863 branch.unlock()
863 self.assertEqual(1, len(self._branch_changed_log))864 self.assertEqual(1, len(self._branch_changed_log))
864865
866 def test_branch_unlock_reports_users_id(self):
867 # Unlocking a branch calls branchChanged on the branch filesystem
868 # endpoint with the logged in user's id.
869 db_branch = self.factory.makeAnyBranch(
870 branch_type=BranchType.HOSTED, owner=self.requester)
871 branch = self.make_branch(db_branch.unique_name)
872 del self._branch_changed_log[:]
873 branch.lock_write()
874 branch.unlock()
875 self.assertEqual(1, len(self._branch_changed_log))
876 self.assertEqual(
877 self.requester.id, self._branch_changed_log[0]['user_id'])
878
865 def test_branch_unlock_reports_stacked_on_url(self):879 def test_branch_unlock_reports_stacked_on_url(self):
866 # Unlocking a branch reports the stacked on URL to the branch880 # Unlocking a branch reports the stacked on URL to the branch
867 # filesystem endpoint.881 # filesystem endpoint.
868882
=== modified file 'lib/lp/codehosting/vfs/transport.py'
--- lib/lp/codehosting/vfs/transport.py 2010-03-19 10:43:51 +0000
+++ lib/lp/codehosting/vfs/transport.py 2010-04-27 02:24:09 +0000
@@ -16,7 +16,6 @@
16 'AsyncVirtualTransport',16 'AsyncVirtualTransport',
17 'get_chrooted_transport',17 'get_chrooted_transport',
18 'get_readonly_transport',18 'get_readonly_transport',
19 '_MultiServer',
20 'SynchronousAdapter',19 'SynchronousAdapter',
21 'TranslationError',20 'TranslationError',
22 ]21 ]
@@ -69,25 +68,6 @@
69 return get_transport('readonly+' + transport.base)68 return get_transport('readonly+' + transport.base)
7069
7170
72class _MultiServer(Server):
73 """Server that wraps around multiple servers."""
74
75 def __init__(self, *servers):
76 self._servers = servers
77
78 def start_server(self):
79 for server in self._servers:
80 server.start_server()
81
82 def destroy(self):
83 for server in reversed(self._servers):
84 server.destroy()
85
86 def stop_server(self):
87 for server in reversed(self._servers):
88 server.stop_server()
89
90
91class AsyncVirtualTransport(Transport):71class AsyncVirtualTransport(Transport):
92 """A transport for a virtual file system.72 """A transport for a virtual file system.
9373
9474
=== modified file 'lib/lp/testing/__init__.py'
--- lib/lp/testing/__init__.py 2010-04-27 02:24:00 +0000
+++ lib/lp/testing/__init__.py 2010-04-27 02:24:09 +0000
@@ -499,25 +499,6 @@
499 get_transport(base).create_prefix()499 get_transport(base).create_prefix()
500 return os.path.join(base, branch_id_to_path(branch.id))500 return os.path.join(base, branch_id_to_path(branch.id))
501501
502 def createMirroredBranchAndTree(self):
503 """Create a database branch, bzr branch and bzr checkout.
504
505 This always uses the configured mirrored area, ignoring whatever
506 server might be providing lp-mirrored: urls.
507
508 Unlike normal codehosting operation, the working tree is stored in the
509 branch directory.
510
511 The branch and tree files are automatically deleted at the end of the
512 test.
513
514 :return: a `Branch` and a workingtree.
515 """
516 db_branch = self.factory.makeAnyBranch()
517 bzr_branch = self.createBranchAtURL(self.getBranchPath(
518 db_branch, config.codehosting.internal_branch_by_id_root))
519 return db_branch, bzr_branch.bzrdir.open_workingtree()
520
521 def useTempBzrHome(self):502 def useTempBzrHome(self):
522 self.useTempDir()503 self.useTempDir()
523 # Avoid leaking local user configuration into tests.504 # Avoid leaking local user configuration into tests.
524505
=== modified file 'lib/lp/testing/factory.py'
--- lib/lp/testing/factory.py 2010-04-27 02:24:00 +0000
+++ lib/lp/testing/factory.py 2010-04-27 02:24:09 +0000
@@ -1058,7 +1058,8 @@
1058 parent = revision1058 parent = revision
1059 parent_ids = [parent.revision_id]1059 parent_ids = [parent.revision_id]
1060 branch.startMirroring()1060 branch.startMirroring()
1061 branch.mirrorComplete(parent.revision_id)1061 removeSecurityProxy(branch).branchChanged(
1062 '', parent.revision_id, None, None, None)
1062 branch.updateScannedDetails(parent, sequence)1063 branch.updateScannedDetails(parent, sequence)
10631064
1064 def makeBranchRevision(self, branch, revision_id, sequence=None):1065 def makeBranchRevision(self, branch, revision_id, sequence=None):
10651066
=== modified file 'lib/lp/translations/tests/test_rosetta_branches_script.py'
--- lib/lp/translations/tests/test_rosetta_branches_script.py 2009-09-03 20:29:25 +0000
+++ lib/lp/translations/tests/test_rosetta_branches_script.py 2010-04-27 02:24:09 +0000
@@ -38,9 +38,9 @@
38 queue.remove(entry)38 queue.remove(entry)
3939
40 def _setup_series_branch(self, pot_path):40 def _setup_series_branch(self, pot_path):
41 self.useTempBzrHome()41 self.useBzrBranches()
42 pot_content = self.factory.getUniqueString()42 pot_content = self.factory.getUniqueString()
43 branch, tree = self.createMirroredBranchAndTree()43 branch, tree = self.create_branch_and_tree()
44 tree.bzrdir.root_transport.put_bytes(pot_path, pot_content)44 tree.bzrdir.root_transport.put_bytes(pot_path, pot_content)
45 tree.add(pot_path)45 tree.add(pot_path)
46 revision_id = tree.commit("first commit")46 revision_id = tree.commit("first commit")
4747
=== modified file 'scripts/update-stacked-on.py'
--- scripts/update-stacked-on.py 2010-04-27 02:24:00 +0000
+++ scripts/update-stacked-on.py 2010-04-27 02:24:09 +0000
@@ -22,50 +22,16 @@
2222
23import _pythonpath23import _pythonpath
24import sys24import sys
25import xmlrpclib
2625
27from bzrlib.bzrdir import BzrDir26from bzrlib.bzrdir import BzrDir
28from bzrlib.config import TransportConfig27from bzrlib.config import TransportConfig
29from bzrlib import errors28from bzrlib import errors
3029
31from lp.codehosting.vfs.branchfs import LaunchpadInternalServer30from lp.codehosting.vfs import get_rw_server, get_ro_server
32from lp.codehosting.vfs import BlockingProxy
33from lp.codehosting.vfs.transport import (
34 get_chrooted_transport, get_readonly_transport, _MultiServer)
35from lp.codehosting.bzrutils import get_branch_stacked_on_url31from lp.codehosting.bzrutils import get_branch_stacked_on_url
36from canonical.config import config
37from lp.services.scripts.base import LaunchpadScript32from lp.services.scripts.base import LaunchpadScript
3833
3934
40def get_server(read_only):
41 """Get a server that can write to both hosted and mirrored areas."""
42 proxy = xmlrpclib.ServerProxy(config.codehosting.codehosting_endpoint)
43 authserver = BlockingProxy(proxy)
44 hosted_transport = get_chrooted_transport(
45 config.codehosting.hosted_branches_root)
46 if read_only:
47 hosted_transport = get_readonly_transport(hosted_transport)
48 mirrored_transport = get_chrooted_transport(
49 config.codehosting.mirrored_branches_root)
50 if read_only:
51 mirrored_transport = get_readonly_transport(mirrored_transport)
52 hosted_server = LaunchpadInternalServer(
53 'lp-hosted:///', authserver, hosted_transport)
54 mirrored_server = LaunchpadInternalServer(
55 'lp-mirrored:///', authserver, mirrored_transport)
56 return _MultiServer(hosted_server, mirrored_server)
57
58
59def get_hosted_url(unique_name):
60 """Return the hosted URL for the branch with 'unique_name'."""
61 return 'lp-hosted:///%s' % unique_name
62
63
64def get_mirrored_url(unique_name):
65 """Return the mirrored URL for the branch with 'unique_name'."""
66 return 'lp-mirrored:///%s' % unique_name
67
68
69def set_branch_stacked_on_url(bzrdir, stacked_on_url):35def set_branch_stacked_on_url(bzrdir, stacked_on_url):
70 """Set the stacked_on_location for the branch at 'bzrdir'.36 """Set the stacked_on_location for the branch at 'bzrdir'.
7137
@@ -93,7 +59,10 @@
93 "motions."))59 "motions."))
9460
95 def main(self):61 def main(self):
96 server = get_server(self.options.dry_run)62 if self.options.dry_run:
63 server = get_ro_server()
64 else:
65 server = get_rw_server()
97 server.start_server()66 server.start_server()
98 if self.options.dry_run:67 if self.options.dry_run:
99 self.logger.debug('Running read-only')68 self.logger.debug('Running read-only')
@@ -109,8 +78,7 @@
10978
110 :param branch_id: The database ID of the branch. This is only used for79 :param branch_id: The database ID of the branch. This is only used for
111 logging.80 logging.
112 :param bzr_branch_url: The URL of the Bazaar branch. Normally this is81 :param bzr_branch_url: The lp-internal:/// URL of the Bazaar branch.
113 of the form lp-mirrored:/// or lp-hosted:///.
114 :param stacked_on_location: The location to store in the branch's82 :param stacked_on_location: The location to store in the branch's
115 stacked_on_location configuration variable.83 stacked_on_location configuration variable.
116 """84 """
@@ -165,12 +133,9 @@
165 (branch_id, branch_type, unique_name,133 (branch_id, branch_type, unique_name,
166 stacked_on_name) = branch_info134 stacked_on_name) = branch_info
167 stacked_on_location = '/' + stacked_on_name135 stacked_on_location = '/' + stacked_on_name
168 if branch_type == 'HOSTED':
169 self.updateStackedOn(
170 branch_id, get_hosted_url(unique_name),
171 stacked_on_location)
172 self.updateStackedOn(136 self.updateStackedOn(
173 branch_id, get_mirrored_url(unique_name), stacked_on_location)137 branch_id, 'lp-internal:///' + unique_name,
138 stacked_on_location)
174139
175140
176if __name__ == '__main__':141if __name__ == '__main__':

Subscribers

People subscribed via source and target branches

to status/vote changes: