Merge lp:~mwhudson/launchpad/no-hosted-area-server-catchup into lp:launchpad/db-devel
- no-hosted-area-server-catchup
- Merge into 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 |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Tim Penhey (community) | Approve | ||
Review via email: mp+24098@code.launchpad.net |
Commit message
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.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'cronscripts/rosetta-branches.py' |
2 | --- cronscripts/rosetta-branches.py 2010-02-16 15:25:52 +0000 |
3 | +++ cronscripts/rosetta-branches.py 2010-04-27 02:24:09 +0000 |
4 | @@ -17,7 +17,7 @@ |
5 | from zope.component import getUtility |
6 | |
7 | from canonical.config import config |
8 | -from lp.codehosting.vfs.branchfs import get_scanner_server |
9 | +from lp.codehosting.vfs.branchfs import get_ro_server |
10 | from lp.services.job.runner import JobRunner |
11 | from lp.code.interfaces.branchjob import IRosettaUploadJobSource |
12 | from lp.services.scripts.base import LaunchpadCronScript |
13 | @@ -31,7 +31,7 @@ |
14 | globalErrorUtility.configure('rosettabranches') |
15 | runner = JobRunner.fromReady( |
16 | getUtility(IRosettaUploadJobSource), self.logger) |
17 | - server = get_scanner_server() |
18 | + server = get_ro_server() |
19 | server.start_server() |
20 | try: |
21 | runner.runAll() |
22 | |
23 | === modified file 'cronscripts/sendbranchmail.py' |
24 | --- cronscripts/sendbranchmail.py 2010-02-16 15:25:52 +0000 |
25 | +++ cronscripts/sendbranchmail.py 2010-04-27 02:24:09 +0000 |
26 | @@ -16,7 +16,7 @@ |
27 | from zope.component import getUtility |
28 | |
29 | from canonical.config import config |
30 | -from lp.codehosting.vfs import get_scanner_server |
31 | +from lp.codehosting.vfs import get_ro_server |
32 | from lp.services.job.runner import JobRunner |
33 | from lp.code.interfaces.branchjob import ( |
34 | IRevisionMailJobSource, IRevisionsAddedJobSource) |
35 | @@ -32,7 +32,7 @@ |
36 | jobs = list(getUtility(IRevisionMailJobSource).iterReady()) |
37 | jobs.extend(getUtility(IRevisionsAddedJobSource).iterReady()) |
38 | runner = JobRunner(jobs, self.logger) |
39 | - server = get_scanner_server() |
40 | + server = get_ro_server() |
41 | server.start_server() |
42 | try: |
43 | runner.runAll() |
44 | |
45 | === modified file 'lib/lp/code/model/directbranchcommit.py' |
46 | --- lib/lp/code/model/directbranchcommit.py 2010-04-27 02:24:00 +0000 |
47 | +++ lib/lp/code/model/directbranchcommit.py 2010-04-27 02:24:09 +0000 |
48 | @@ -51,9 +51,9 @@ |
49 | """Create context for direct commit to branch. |
50 | |
51 | Before constructing a `DirectBranchCommit`, set up a server that |
52 | - allows write access to lp-hosted:/// URLs: |
53 | + allows write access to lp-internal:/// URLs: |
54 | |
55 | - bzrserver = get_multi_server(write_hosted=True) |
56 | + bzrserver = get_rw_server() |
57 | bzrserver.start_server() |
58 | try: |
59 | branchcommit = DirectBranchCommit(branch) |
60 | |
61 | === modified file 'lib/lp/code/scripts/tests/test_sendbranchmail.py' |
62 | --- lib/lp/code/scripts/tests/test_sendbranchmail.py 2010-04-01 04:37:30 +0000 |
63 | +++ lib/lp/code/scripts/tests/test_sendbranchmail.py 2010-04-27 02:24:09 +0000 |
64 | @@ -23,7 +23,7 @@ |
65 | layer = ZopelessAppServerLayer |
66 | |
67 | def createBranch(self): |
68 | - branch, tree = self.createMirroredBranchAndTree() |
69 | + branch, tree = self.create_branch_and_tree() |
70 | branch.subscribe(branch.registrant, |
71 | BranchSubscriptionNotificationLevel.FULL, |
72 | BranchSubscriptionDiffSize.WHOLEDIFF, |
73 | @@ -36,7 +36,7 @@ |
74 | |
75 | def test_sendbranchmail(self): |
76 | """Ensure sendbranchmail runs and sends email.""" |
77 | - self.useTempBzrHome() |
78 | + self.useBzrBranches() |
79 | branch, tree = self.createBranch() |
80 | RevisionMailJob.create( |
81 | branch, 1, 'from@example.org', 'body', True, 'foo') |
82 | @@ -68,7 +68,7 @@ |
83 | |
84 | def test_revision_added_job(self): |
85 | """RevisionsAddedJobs are run by sendbranchmail.""" |
86 | - self.useTempBzrHome() |
87 | + self.useBzrBranches() |
88 | branch, tree = self.createBranch() |
89 | tree.bzrdir.root_transport.put_bytes('foo', 'baz') |
90 | tree.commit('Added foo.', rev_id='rev2') |
91 | |
92 | === modified file 'lib/lp/codehosting/puller/tests/test_acceptance.py' |
93 | --- lib/lp/codehosting/puller/tests/test_acceptance.py 2010-04-27 02:24:00 +0000 |
94 | +++ lib/lp/codehosting/puller/tests/test_acceptance.py 2010-04-27 02:24:09 +0000 |
95 | @@ -7,22 +7,18 @@ |
96 | __all__ = [] |
97 | |
98 | |
99 | -import datetime |
100 | import os |
101 | from subprocess import PIPE, Popen |
102 | import unittest |
103 | |
104 | -import pytz |
105 | |
106 | import transaction |
107 | |
108 | from bzrlib.branch import Branch |
109 | from bzrlib.bzrdir import BzrDir |
110 | from bzrlib import errors |
111 | -from bzrlib.transport import get_transport |
112 | from bzrlib.upgrade import upgrade |
113 | -from bzrlib.urlutils import ( |
114 | - join as urljoin, local_path_from_url, local_path_to_url) |
115 | +from bzrlib.urlutils import join as urljoin, local_path_from_url |
116 | from bzrlib.workingtree import WorkingTree |
117 | |
118 | from zope.component import getUtility |
119 | @@ -30,7 +26,7 @@ |
120 | |
121 | from lp.code.enums import BranchType |
122 | from lp.code.interfaces.branchtarget import IBranchTarget |
123 | -from lp.codehosting.vfs import branch_id_to_path, get_lp_server |
124 | +from lp.codehosting.vfs import get_lp_server |
125 | from lp.codehosting.puller.tests import PullerBranchTestCase |
126 | from lp.codehosting.tests.helpers import LoomTestMixin |
127 | from canonical.config import config |
128 | @@ -56,8 +52,7 @@ |
129 | self.makeCleanDirectory( |
130 | local_path_from_url(config.launchpad.bzr_imports_root_url)) |
131 | |
132 | - def assertMirrored(self, db_branch, source_branch, |
133 | - accessing_user=None): |
134 | + def assertMirrored(self, db_branch, source_branch): |
135 | """Assert that 'db_branch' was mirrored succesfully. |
136 | |
137 | This method checks that the fields on db_branch show that the branch |
138 | @@ -73,8 +68,7 @@ |
139 | supplied create a fresh user for this -- but this won't work for a |
140 | private branch. |
141 | """ |
142 | - if accessing_user is None: |
143 | - accessing_user = self.factory.makePerson() |
144 | + accessing_user = self.factory.makePerson() |
145 | transaction.commit() |
146 | self.assertEqual(None, db_branch.mirror_status_message) |
147 | self.assertEqual( |
148 | @@ -219,22 +213,21 @@ |
149 | (defaults to not). |
150 | :return: `IBranch`. |
151 | """ |
152 | - # Make the branch. |
153 | + # Make the branch in the database. |
154 | product = self.factory.makeProduct() |
155 | default_branch = self.factory.makeProductBranch( |
156 | product=product, private=private) |
157 | - default_branch.last_mirrored = datetime.datetime.now(pytz.UTC) |
158 | - # Make it the default stacked-on branch. |
159 | + transaction.commit() |
160 | + # Create the underlying bzr branch. |
161 | + lp_server = self.getLPServerForUser(default_branch.owner) |
162 | + BzrDir.create_branch_convenience( |
163 | + lp_server.get_url() + default_branch.unique_name) |
164 | + transaction.commit() |
165 | + # Make it the default stacked-on branch for the product. |
166 | series = removeSecurityProxy(product.development_focus) |
167 | series.branch = default_branch |
168 | self.assertEqual( |
169 | default_branch, IBranchTarget(product).default_stacked_on_branch) |
170 | - branch_location = urljoin( |
171 | - local_path_to_url(config.codehosting.mirrored_branches_root), |
172 | - branch_id_to_path(default_branch.id)) |
173 | - get_transport(branch_location).create_prefix() |
174 | - BzrDir.create_branch_convenience(branch_location) |
175 | - transaction.commit() |
176 | return default_branch |
177 | |
178 | def test_stack_mirrored_branch(self): |
179 | |
180 | === modified file 'lib/lp/codehosting/puller/tests/test_scheduler.py' |
181 | --- lib/lp/codehosting/puller/tests/test_scheduler.py 2010-04-27 02:24:00 +0000 |
182 | +++ lib/lp/codehosting/puller/tests/test_scheduler.py 2010-04-27 02:24:09 +0000 |
183 | @@ -28,6 +28,7 @@ |
184 | from canonical.launchpad.webapp import errorlog |
185 | from canonical.testing import ( |
186 | reset_logging, TwistedLayer, TwistedAppServerLayer) |
187 | +from lp.code.interfaces.codehosting import LAUNCHPAD_SERVICES |
188 | from lp.codehosting.puller import get_lock_id_for_branch_id, scheduler |
189 | from lp.codehosting.puller.tests import PullerBranchTestCase |
190 | from lp.codehosting.puller.worker import ( |
191 | @@ -454,9 +455,9 @@ |
192 | |
193 | def checkMirrorCompleted(ignored): |
194 | self.assertEqual( |
195 | - [('branchChanged', self.arbitrary_branch_id, stacked_on_url, |
196 | - revid_after, control_string, branch_string, |
197 | - repository_string)], |
198 | + [('branchChanged', LAUNCHPAD_SERVICES, |
199 | + self.arbitrary_branch_id, stacked_on_url, revid_after, |
200 | + control_string, branch_string, repository_string)], |
201 | self.status_client.calls) |
202 | return deferred.addCallback(checkMirrorCompleted) |
203 | |
204 | @@ -680,8 +681,9 @@ |
205 | repository_string = \ |
206 | default_format.repository_format.get_format_string() |
207 | self.assertEqual( |
208 | - [('branchChanged', self.db_branch.id, '', revision_id, |
209 | - control_string, branch_string, repository_string)], |
210 | + [('branchChanged', LAUNCHPAD_SERVICES, self.db_branch.id, '', |
211 | + revision_id, control_string, branch_string, |
212 | + repository_string)], |
213 | self.client.calls) |
214 | return ignored |
215 | deferred.addCallback(check_authserver_called) |
216 | |
217 | === modified file 'lib/lp/codehosting/vfs/__init__.py' |
218 | --- lib/lp/codehosting/vfs/__init__.py 2010-04-27 02:24:00 +0000 |
219 | +++ lib/lp/codehosting/vfs/__init__.py 2010-04-27 02:24:09 +0000 |
220 | @@ -9,17 +9,14 @@ |
221 | 'branch_id_to_path', |
222 | 'BranchFileSystemClient', |
223 | 'get_lp_server', |
224 | - 'get_multi_server', |
225 | 'get_ro_server', |
226 | 'get_rw_server', |
227 | - 'get_scanner_server', |
228 | 'LaunchpadServer', |
229 | 'make_branch_mirrorer', |
230 | ] |
231 | |
232 | from lp.codehosting.vfs.branchfs import ( |
233 | - AsyncLaunchpadTransport, branch_id_to_path, get_lp_server, |
234 | - get_multi_server, get_ro_server, get_rw_server, get_scanner_server, |
235 | - LaunchpadServer, make_branch_mirrorer) |
236 | + AsyncLaunchpadTransport, LaunchpadServer, branch_id_to_path, |
237 | + get_lp_server, get_ro_server, get_rw_server, make_branch_mirrorer) |
238 | from lp.codehosting.vfs.branchfsclient import ( |
239 | BlockingProxy,BranchFileSystemClient) |
240 | |
241 | === modified file 'lib/lp/codehosting/vfs/branchfs.py' |
242 | --- lib/lp/codehosting/vfs/branchfs.py 2010-04-27 02:24:00 +0000 |
243 | +++ lib/lp/codehosting/vfs/branchfs.py 2010-04-27 02:24:09 +0000 |
244 | @@ -54,10 +54,8 @@ |
245 | 'BranchPolicy', |
246 | 'DirectDatabaseLaunchpadServer', |
247 | 'get_lp_server', |
248 | - 'get_multi_server', |
249 | 'get_ro_server', |
250 | 'get_rw_server', |
251 | - 'get_scanner_server', |
252 | 'make_branch_mirrorer', |
253 | 'LaunchpadInternalServer', |
254 | 'LaunchpadServer', |
255 | @@ -88,8 +86,8 @@ |
256 | from lp.codehosting.vfs.branchfsclient import ( |
257 | BlockingProxy, BranchFileSystemClient) |
258 | from lp.codehosting.vfs.transport import ( |
259 | - AsyncVirtualServer, AsyncVirtualTransport, _MultiServer, |
260 | - get_chrooted_transport, get_readonly_transport, TranslationError) |
261 | + AsyncVirtualServer, AsyncVirtualTransport, TranslationError, |
262 | + get_chrooted_transport, get_readonly_transport) |
263 | from canonical.config import config |
264 | from canonical.launchpad.xmlrpc import faults |
265 | from lp.code.enums import BranchType |
266 | @@ -177,7 +175,6 @@ |
267 | return LaunchpadInternalServer( |
268 | 'lp-internal:///', codehosting_endpoint, branch_transport) |
269 | |
270 | -get_scanner_server = get_ro_server |
271 | |
272 | def get_rw_server(direct_database=False): |
273 | """Get a server that can write to the Launchpad branch vfs. |
274 | @@ -200,48 +197,6 @@ |
275 | 'lp-internal:///', codehosting_endpoint, transport) |
276 | |
277 | |
278 | -def get_multi_server(write_hosted=False, write_mirrored=False, |
279 | - direct_database=False): |
280 | - """Get a server with access to both mirrored and hosted areas. |
281 | - |
282 | - The server wraps up two `LaunchpadInternalServer`s or |
283 | - `DirectDatabaseLaunchpadServer`s. One server points to the hosted branch |
284 | - area and the other points to the mirrored area. |
285 | - |
286 | - Write permision defaults to False, but can be overridden. |
287 | - |
288 | - :param write_hosted: if True, lp-hosted URLs are writeable. Otherwise, |
289 | - they are read-only. |
290 | - :param write_mirrored: if True, lp-mirrored URLs are writeable. |
291 | - Otherwise, they are read-only. |
292 | - |
293 | - :param direct_database: if True, use a server implementation that talks |
294 | - directly to the database. If False, the default, use a server |
295 | - implementation that talks to the internal XML-RPC server. |
296 | - """ |
297 | - # XXX 2010-04-20, MichaelHudson: this function will disappear in a later |
298 | - # pipe. |
299 | - hosted_transport = get_chrooted_transport( |
300 | - config.codehosting.mirrored_branches_root, mkdir=True) |
301 | - if not write_hosted: |
302 | - hosted_transport = get_readonly_transport(hosted_transport) |
303 | - mirrored_transport = get_chrooted_transport( |
304 | - config.codehosting.mirrored_branches_root, mkdir=True) |
305 | - if not write_mirrored: |
306 | - mirrored_transport = get_readonly_transport(mirrored_transport) |
307 | - if direct_database: |
308 | - make_server = DirectDatabaseLaunchpadServer |
309 | - else: |
310 | - proxy = xmlrpclib.ServerProxy(config.codehosting.codehosting_endpoint) |
311 | - codehosting_endpoint = BlockingProxy(proxy) |
312 | - def make_server(scheme, transport): |
313 | - return LaunchpadInternalServer( |
314 | - scheme, codehosting_endpoint, transport) |
315 | - hosted_server = make_server('lp-hosted:///', hosted_transport) |
316 | - mirrored_server = make_server('lp-mirrored:///', mirrored_transport) |
317 | - return _MultiServer(hosted_server, mirrored_server) |
318 | - |
319 | - |
320 | class ITransportDispatch(Interface): |
321 | """Turns descriptions of transports into transports.""" |
322 | |
323 | |
324 | === modified file 'lib/lp/codehosting/vfs/tests/test_branchfs.py' |
325 | --- lib/lp/codehosting/vfs/tests/test_branchfs.py 2010-04-27 02:24:00 +0000 |
326 | +++ lib/lp/codehosting/vfs/tests/test_branchfs.py 2010-04-27 02:24:09 +0000 |
327 | @@ -826,11 +826,12 @@ |
328 | self.backing_transport = MemoryTransport() |
329 | self.disable_directory_isolation() |
330 | |
331 | - def _replacement_branchChanged(self, branch_id, stacked_on_url, |
332 | + def _replacement_branchChanged(self, user_id, branch_id, stacked_on_url, |
333 | last_revision, *format_strings): |
334 | self._branch_changed_log.append(dict( |
335 | - branch_id=branch_id, stacked_on_url=stacked_on_url, |
336 | - last_revision=last_revision, format_strings=format_strings)) |
337 | + user_id=user_id, branch_id=branch_id, |
338 | + stacked_on_url=stacked_on_url, last_revision=last_revision, |
339 | + format_strings=format_strings)) |
340 | |
341 | def get_server(self): |
342 | if self._server is None: |
343 | @@ -862,6 +863,19 @@ |
344 | branch.unlock() |
345 | self.assertEqual(1, len(self._branch_changed_log)) |
346 | |
347 | + def test_branch_unlock_reports_users_id(self): |
348 | + # Unlocking a branch calls branchChanged on the branch filesystem |
349 | + # endpoint with the logged in user's id. |
350 | + db_branch = self.factory.makeAnyBranch( |
351 | + branch_type=BranchType.HOSTED, owner=self.requester) |
352 | + branch = self.make_branch(db_branch.unique_name) |
353 | + del self._branch_changed_log[:] |
354 | + branch.lock_write() |
355 | + branch.unlock() |
356 | + self.assertEqual(1, len(self._branch_changed_log)) |
357 | + self.assertEqual( |
358 | + self.requester.id, self._branch_changed_log[0]['user_id']) |
359 | + |
360 | def test_branch_unlock_reports_stacked_on_url(self): |
361 | # Unlocking a branch reports the stacked on URL to the branch |
362 | # filesystem endpoint. |
363 | |
364 | === modified file 'lib/lp/codehosting/vfs/transport.py' |
365 | --- lib/lp/codehosting/vfs/transport.py 2010-03-19 10:43:51 +0000 |
366 | +++ lib/lp/codehosting/vfs/transport.py 2010-04-27 02:24:09 +0000 |
367 | @@ -16,7 +16,6 @@ |
368 | 'AsyncVirtualTransport', |
369 | 'get_chrooted_transport', |
370 | 'get_readonly_transport', |
371 | - '_MultiServer', |
372 | 'SynchronousAdapter', |
373 | 'TranslationError', |
374 | ] |
375 | @@ -69,25 +68,6 @@ |
376 | return get_transport('readonly+' + transport.base) |
377 | |
378 | |
379 | -class _MultiServer(Server): |
380 | - """Server that wraps around multiple servers.""" |
381 | - |
382 | - def __init__(self, *servers): |
383 | - self._servers = servers |
384 | - |
385 | - def start_server(self): |
386 | - for server in self._servers: |
387 | - server.start_server() |
388 | - |
389 | - def destroy(self): |
390 | - for server in reversed(self._servers): |
391 | - server.destroy() |
392 | - |
393 | - def stop_server(self): |
394 | - for server in reversed(self._servers): |
395 | - server.stop_server() |
396 | - |
397 | - |
398 | class AsyncVirtualTransport(Transport): |
399 | """A transport for a virtual file system. |
400 | |
401 | |
402 | === modified file 'lib/lp/testing/__init__.py' |
403 | --- lib/lp/testing/__init__.py 2010-04-27 02:24:00 +0000 |
404 | +++ lib/lp/testing/__init__.py 2010-04-27 02:24:09 +0000 |
405 | @@ -499,25 +499,6 @@ |
406 | get_transport(base).create_prefix() |
407 | return os.path.join(base, branch_id_to_path(branch.id)) |
408 | |
409 | - def createMirroredBranchAndTree(self): |
410 | - """Create a database branch, bzr branch and bzr checkout. |
411 | - |
412 | - This always uses the configured mirrored area, ignoring whatever |
413 | - server might be providing lp-mirrored: urls. |
414 | - |
415 | - Unlike normal codehosting operation, the working tree is stored in the |
416 | - branch directory. |
417 | - |
418 | - The branch and tree files are automatically deleted at the end of the |
419 | - test. |
420 | - |
421 | - :return: a `Branch` and a workingtree. |
422 | - """ |
423 | - db_branch = self.factory.makeAnyBranch() |
424 | - bzr_branch = self.createBranchAtURL(self.getBranchPath( |
425 | - db_branch, config.codehosting.internal_branch_by_id_root)) |
426 | - return db_branch, bzr_branch.bzrdir.open_workingtree() |
427 | - |
428 | def useTempBzrHome(self): |
429 | self.useTempDir() |
430 | # Avoid leaking local user configuration into tests. |
431 | |
432 | === modified file 'lib/lp/testing/factory.py' |
433 | --- lib/lp/testing/factory.py 2010-04-27 02:24:00 +0000 |
434 | +++ lib/lp/testing/factory.py 2010-04-27 02:24:09 +0000 |
435 | @@ -1058,7 +1058,8 @@ |
436 | parent = revision |
437 | parent_ids = [parent.revision_id] |
438 | branch.startMirroring() |
439 | - branch.mirrorComplete(parent.revision_id) |
440 | + removeSecurityProxy(branch).branchChanged( |
441 | + '', parent.revision_id, None, None, None) |
442 | branch.updateScannedDetails(parent, sequence) |
443 | |
444 | def makeBranchRevision(self, branch, revision_id, sequence=None): |
445 | |
446 | === modified file 'lib/lp/translations/tests/test_rosetta_branches_script.py' |
447 | --- lib/lp/translations/tests/test_rosetta_branches_script.py 2009-09-03 20:29:25 +0000 |
448 | +++ lib/lp/translations/tests/test_rosetta_branches_script.py 2010-04-27 02:24:09 +0000 |
449 | @@ -38,9 +38,9 @@ |
450 | queue.remove(entry) |
451 | |
452 | def _setup_series_branch(self, pot_path): |
453 | - self.useTempBzrHome() |
454 | + self.useBzrBranches() |
455 | pot_content = self.factory.getUniqueString() |
456 | - branch, tree = self.createMirroredBranchAndTree() |
457 | + branch, tree = self.create_branch_and_tree() |
458 | tree.bzrdir.root_transport.put_bytes(pot_path, pot_content) |
459 | tree.add(pot_path) |
460 | revision_id = tree.commit("first commit") |
461 | |
462 | === modified file 'scripts/update-stacked-on.py' |
463 | --- scripts/update-stacked-on.py 2010-04-27 02:24:00 +0000 |
464 | +++ scripts/update-stacked-on.py 2010-04-27 02:24:09 +0000 |
465 | @@ -22,50 +22,16 @@ |
466 | |
467 | import _pythonpath |
468 | import sys |
469 | -import xmlrpclib |
470 | |
471 | from bzrlib.bzrdir import BzrDir |
472 | from bzrlib.config import TransportConfig |
473 | from bzrlib import errors |
474 | |
475 | -from lp.codehosting.vfs.branchfs import LaunchpadInternalServer |
476 | -from lp.codehosting.vfs import BlockingProxy |
477 | -from lp.codehosting.vfs.transport import ( |
478 | - get_chrooted_transport, get_readonly_transport, _MultiServer) |
479 | +from lp.codehosting.vfs import get_rw_server, get_ro_server |
480 | from lp.codehosting.bzrutils import get_branch_stacked_on_url |
481 | -from canonical.config import config |
482 | from lp.services.scripts.base import LaunchpadScript |
483 | |
484 | |
485 | -def get_server(read_only): |
486 | - """Get a server that can write to both hosted and mirrored areas.""" |
487 | - proxy = xmlrpclib.ServerProxy(config.codehosting.codehosting_endpoint) |
488 | - authserver = BlockingProxy(proxy) |
489 | - hosted_transport = get_chrooted_transport( |
490 | - config.codehosting.hosted_branches_root) |
491 | - if read_only: |
492 | - hosted_transport = get_readonly_transport(hosted_transport) |
493 | - mirrored_transport = get_chrooted_transport( |
494 | - config.codehosting.mirrored_branches_root) |
495 | - if read_only: |
496 | - mirrored_transport = get_readonly_transport(mirrored_transport) |
497 | - hosted_server = LaunchpadInternalServer( |
498 | - 'lp-hosted:///', authserver, hosted_transport) |
499 | - mirrored_server = LaunchpadInternalServer( |
500 | - 'lp-mirrored:///', authserver, mirrored_transport) |
501 | - return _MultiServer(hosted_server, mirrored_server) |
502 | - |
503 | - |
504 | -def get_hosted_url(unique_name): |
505 | - """Return the hosted URL for the branch with 'unique_name'.""" |
506 | - return 'lp-hosted:///%s' % unique_name |
507 | - |
508 | - |
509 | -def get_mirrored_url(unique_name): |
510 | - """Return the mirrored URL for the branch with 'unique_name'.""" |
511 | - return 'lp-mirrored:///%s' % unique_name |
512 | - |
513 | - |
514 | def set_branch_stacked_on_url(bzrdir, stacked_on_url): |
515 | """Set the stacked_on_location for the branch at 'bzrdir'. |
516 | |
517 | @@ -93,7 +59,10 @@ |
518 | "motions.")) |
519 | |
520 | def main(self): |
521 | - server = get_server(self.options.dry_run) |
522 | + if self.options.dry_run: |
523 | + server = get_ro_server() |
524 | + else: |
525 | + server = get_rw_server() |
526 | server.start_server() |
527 | if self.options.dry_run: |
528 | self.logger.debug('Running read-only') |
529 | @@ -109,8 +78,7 @@ |
530 | |
531 | :param branch_id: The database ID of the branch. This is only used for |
532 | logging. |
533 | - :param bzr_branch_url: The URL of the Bazaar branch. Normally this is |
534 | - of the form lp-mirrored:/// or lp-hosted:///. |
535 | + :param bzr_branch_url: The lp-internal:/// URL of the Bazaar branch. |
536 | :param stacked_on_location: The location to store in the branch's |
537 | stacked_on_location configuration variable. |
538 | """ |
539 | @@ -165,12 +133,9 @@ |
540 | (branch_id, branch_type, unique_name, |
541 | stacked_on_name) = branch_info |
542 | stacked_on_location = '/' + stacked_on_name |
543 | - if branch_type == 'HOSTED': |
544 | - self.updateStackedOn( |
545 | - branch_id, get_hosted_url(unique_name), |
546 | - stacked_on_location) |
547 | self.updateStackedOn( |
548 | - branch_id, get_mirrored_url(unique_name), stacked_on_location) |
549 | + branch_id, 'lp-internal:///' + unique_name, |
550 | + stacked_on_location) |
551 | |
552 | |
553 | if __name__ == '__main__': |
This is all good.