Merge lp:~mwhudson/launchpad/no-hosted-area-fix-branch-distro into lp:launchpad
- no-hosted-area-fix-branch-distro
- Merge into devel
Proposed by
Michael Hudson-Doyle
Status: | Merged |
---|---|
Approved by: | Tim Penhey |
Approved revision: | no longer in the source branch. |
Merged at revision: | 10828 |
Proposed branch: | lp:~mwhudson/launchpad/no-hosted-area-fix-branch-distro |
Merge into: | lp:launchpad |
Prerequisite: | lp:~mwhudson/launchpad/no-hosted-area-remove-mirrorComplete |
Diff against target: |
611 lines (+116/-250) 7 files modified
lib/lp/code/model/branch.py (+0/-4) lib/lp/code/model/tests/test_branch.py (+0/-6) lib/lp/codehosting/branchdistro.py (+64/-78) lib/lp/codehosting/tests/test_branchdistro.py (+33/-143) lib/lp/codehosting/vfs/branchfs.py (+13/-6) lib/lp/testing/__init__.py (+4/-10) scripts/branch-distro.py (+2/-3) |
To merge this branch: | bzr merge lp:~mwhudson/launchpad/no-hosted-area-fix-branch-distro |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Tim Penhey (community) | Approve | ||
Review via email: mp+23896@code.launchpad.net |
Commit message
Description of the change
Hi Tim,
This branch fixes the branch-distro.py script to work without the hosted/mirror split. It's quite a bit simpler -- a shame that we're not quite going to get this landed in time to use it for opening maverick! Oh well.
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 'lib/lp/code/model/branch.py' |
2 | --- lib/lp/code/model/branch.py 2010-04-27 02:13:58 +0000 |
3 | +++ lib/lp/code/model/branch.py 2010-04-27 02:14:19 +0000 |
4 | @@ -873,10 +873,6 @@ |
5 | # another RCS system such as CVS. |
6 | prefix = config.launchpad.bzr_imports_root_url |
7 | return urlappend(prefix, '%08x' % self.id) |
8 | - elif self.branch_type == BranchType.HOSTED: |
9 | - # This is a push branch, hosted on Launchpad (pushed there by |
10 | - # users via sftp or bzr+ssh). |
11 | - return 'lp-hosted:///%s' % (self.unique_name,) |
12 | else: |
13 | raise AssertionError("No pull URL for %r" % (self,)) |
14 | |
15 | |
16 | === modified file 'lib/lp/code/model/tests/test_branch.py' |
17 | --- lib/lp/code/model/tests/test_branch.py 2010-04-27 02:13:58 +0000 |
18 | +++ lib/lp/code/model/tests/test_branch.py 2010-04-27 02:14:19 +0000 |
19 | @@ -260,12 +260,6 @@ |
20 | |
21 | layer = DatabaseFunctionalLayer |
22 | |
23 | - def test_pullURLHosted(self): |
24 | - # Hosted branches are pulled from internal Launchpad URLs. |
25 | - branch = self.factory.makeAnyBranch(branch_type=BranchType.HOSTED) |
26 | - self.assertEqual( |
27 | - 'lp-hosted:///%s' % branch.unique_name, branch.getPullURL()) |
28 | - |
29 | def test_pullURLMirrored(self): |
30 | # Mirrored branches are pulled from their actual URLs -- that's the |
31 | # point. |
32 | |
33 | === modified file 'lib/lp/codehosting/branchdistro.py' |
34 | --- lib/lp/codehosting/branchdistro.py 2009-10-26 22:37:15 +0000 |
35 | +++ lib/lp/codehosting/branchdistro.py 2010-04-27 02:14:19 +0000 |
36 | @@ -21,8 +21,6 @@ |
37 | from bzrlib.bzrdir import BzrDir |
38 | from bzrlib.errors import NotBranchError, NotStacked |
39 | |
40 | -from lazr.uri import URI |
41 | - |
42 | import transaction |
43 | |
44 | from zope.component import getUtility |
45 | @@ -79,12 +77,9 @@ |
46 | # location so that it works to set the stacked on url to '/' + a |
47 | # unique_name. |
48 | new_location_bzrdir = BzrDir.open( |
49 | - str(URI( |
50 | - scheme=scheme, host='', path='/' + new_db_branch.unique_name))) |
51 | + scheme + ':///' + new_db_branch.unique_name) |
52 | old_location_bzrdir = new_location_bzrdir.clone( |
53 | - str(URI( |
54 | - scheme=scheme, host='', path='/' + old_db_branch.unique_name)), |
55 | - revision_id='null:') |
56 | + scheme + ':///' + old_db_branch.unique_name, revision_id='null:') |
57 | |
58 | # Set the stacked on url for old location. |
59 | old_location_branch = old_location_bzrdir.open_branch() |
60 | @@ -207,8 +202,7 @@ |
61 | |
62 | This function checks that every official package branch in the old |
63 | distroseries has a matching branch in the new distroseries and that |
64 | - stacking is set up as we expect in both the hosted and mirrored areas |
65 | - on disk. |
66 | + stacking is set up as we expect on disk. |
67 | |
68 | Every branch will be checked, even if some fail. |
69 | |
70 | @@ -234,8 +228,7 @@ |
71 | """Check a branch in the old distroseries has been copied to the new. |
72 | |
73 | This function checks that `old_db_branch` has a matching branch in the |
74 | - new distroseries and that stacking is set up as we expect in both the |
75 | - hosted and mirrored areas on disk. |
76 | + new distroseries and that stacking is set up as we expect on disk. |
77 | |
78 | This function simply returns True or False -- any problems will be |
79 | logged to ``self.logger``. |
80 | @@ -258,71 +251,67 @@ |
81 | ok = self.checkConsistentOfficialPackageBranch(new_db_branch) |
82 | if not ok: |
83 | return ok |
84 | - # for both mirrored and hosted areas: |
85 | - for scheme in 'lp-mirrored', 'lp-hosted': |
86 | - # the branch in the new distroseries is unstacked |
87 | - new_location = str(URI( |
88 | - scheme=scheme, host='', path='/' + new_db_branch.unique_name)) |
89 | - try: |
90 | - new_bzr_branch = Branch.open(new_location) |
91 | - except NotBranchError: |
92 | - self.logger.warning( |
93 | - "No bzr branch at new location %s", new_location) |
94 | - ok = False |
95 | - else: |
96 | - try: |
97 | - new_stacked_on_url = new_bzr_branch.get_stacked_on_url() |
98 | - ok = False |
99 | - self.logger.warning( |
100 | - "New branch at %s is stacked on %s, should be " |
101 | - "unstacked.", new_location, new_stacked_on_url) |
102 | - except NotStacked: |
103 | - pass |
104 | - # The branch in the old distroseries is stacked on that in the |
105 | - # new. |
106 | - old_location = str(URI( |
107 | - scheme=scheme, host='', path='/' + old_db_branch.unique_name)) |
108 | - try: |
109 | - old_bzr_branch = Branch.open(old_location) |
110 | - except NotBranchError: |
111 | - self.logger.warning( |
112 | - "No bzr branch at old location %s", old_location) |
113 | - ok = False |
114 | - else: |
115 | - try: |
116 | - old_stacked_on_url = old_bzr_branch.get_stacked_on_url() |
117 | - if old_stacked_on_url != '/' + new_db_branch.unique_name: |
118 | - self.logger.warning( |
119 | - "Old branch at %s is stacked on %s, should be " |
120 | - "stacked on %s", old_location, old_stacked_on_url, |
121 | - '/' + new_db_branch.unique_name) |
122 | - ok = False |
123 | - except NotStacked: |
124 | - self.logger.warning( |
125 | - "Old branch at %s is not stacked, should be stacked " |
126 | - "on %s", old_location, |
127 | + # the branch in the new distroseries is unstacked |
128 | + new_location = 'lp-internal:///' + new_db_branch.unique_name |
129 | + try: |
130 | + new_bzr_branch = Branch.open(new_location) |
131 | + except NotBranchError: |
132 | + self.logger.warning( |
133 | + "No bzr branch at new location %s", new_location) |
134 | + ok = False |
135 | + else: |
136 | + try: |
137 | + new_stacked_on_url = new_bzr_branch.get_stacked_on_url() |
138 | + ok = False |
139 | + self.logger.warning( |
140 | + "New branch at %s is stacked on %s, should be " |
141 | + "unstacked.", new_location, new_stacked_on_url) |
142 | + except NotStacked: |
143 | + pass |
144 | + # The branch in the old distroseries is stacked on that in the |
145 | + # new. |
146 | + old_location = 'lp-internal:///' + old_db_branch.unique_name |
147 | + try: |
148 | + old_bzr_branch = Branch.open(old_location) |
149 | + except NotBranchError: |
150 | + self.logger.warning( |
151 | + "No bzr branch at old location %s", old_location) |
152 | + ok = False |
153 | + else: |
154 | + try: |
155 | + old_stacked_on_url = old_bzr_branch.get_stacked_on_url() |
156 | + if old_stacked_on_url != '/' + new_db_branch.unique_name: |
157 | + self.logger.warning( |
158 | + "Old branch at %s is stacked on %s, should be " |
159 | + "stacked on %s", old_location, old_stacked_on_url, |
160 | '/' + new_db_branch.unique_name) |
161 | ok = False |
162 | - # The branch in the old distroseries has no revisions in its |
163 | - # repository. We open the repository independently of the |
164 | - # branch because the branch's repository has had its fallback |
165 | - # location activated. Note that this check might fail if new |
166 | - # revisions get pushed to the branch in the old distroseries, |
167 | - # which shouldn't happen but isn't totally impossible. |
168 | - old_repo = BzrDir.open(old_location).open_repository() |
169 | - if len(old_repo.all_revision_ids()) > 0: |
170 | - self.logger.warning( |
171 | - "Repository at %s has %s revisions.", |
172 | - old_location, len(old_repo.all_revision_ids())) |
173 | - ok = False |
174 | - # The branch in the old distroseries has at least some |
175 | - # history. (We can't check that the tips are the same because |
176 | - # the branch in the new distroseries might have new revisons). |
177 | - if old_bzr_branch.last_revision() == 'null:': |
178 | - self.logger.warning( |
179 | - "Old branch at %s has null tip revision.", |
180 | - old_location) |
181 | - ok = False |
182 | + except NotStacked: |
183 | + self.logger.warning( |
184 | + "Old branch at %s is not stacked, should be stacked " |
185 | + "on %s", old_location, |
186 | + '/' + new_db_branch.unique_name) |
187 | + ok = False |
188 | + # The branch in the old distroseries has no revisions in its |
189 | + # repository. We open the repository independently of the |
190 | + # branch because the branch's repository has had its fallback |
191 | + # location activated. Note that this check might fail if new |
192 | + # revisions get pushed to the branch in the old distroseries, |
193 | + # which shouldn't happen but isn't totally impossible. |
194 | + old_repo = BzrDir.open(old_location).open_repository() |
195 | + if len(old_repo.all_revision_ids()) > 0: |
196 | + self.logger.warning( |
197 | + "Repository at %s has %s revisions.", |
198 | + old_location, len(old_repo.all_revision_ids())) |
199 | + ok = False |
200 | + # The branch in the old distroseries has at least some |
201 | + # history. (We can't check that the tips are the same because |
202 | + # the branch in the new distroseries might have new revisons). |
203 | + if old_bzr_branch.last_revision() == 'null:': |
204 | + self.logger.warning( |
205 | + "Old branch at %s has null tip revision.", |
206 | + old_location) |
207 | + ok = False |
208 | return ok |
209 | |
210 | def makeOneNewBranch(self, old_db_branch): |
211 | @@ -357,9 +346,6 @@ |
212 | # again. So commit before doing that. |
213 | transaction.commit() |
214 | switch_branches( |
215 | - config.codehosting.hosted_branches_root, |
216 | - 'lp-hosted', old_db_branch, new_db_branch) |
217 | - switch_branches( |
218 | config.codehosting.mirrored_branches_root, |
219 | - 'lp-mirrored', old_db_branch, new_db_branch) |
220 | + 'lp-internal', old_db_branch, new_db_branch) |
221 | return new_db_branch |
222 | |
223 | === modified file 'lib/lp/codehosting/tests/test_branchdistro.py' |
224 | --- lib/lp/codehosting/tests/test_branchdistro.py 2010-01-20 23:10:44 +0000 |
225 | +++ lib/lp/codehosting/tests/test_branchdistro.py 2010-04-27 02:14:19 +0000 |
226 | @@ -118,12 +118,8 @@ |
227 | transaction.commit() |
228 | |
229 | _, tree = self.create_branch_and_tree( |
230 | - tree_location=self.factory.getUniqueString(), db_branch=db_branch, |
231 | - hosted=True) |
232 | + tree_location=self.factory.getUniqueString(), db_branch=db_branch) |
233 | tree.commit('') |
234 | - mirrored_branch = BzrDir.create_branch_convenience( |
235 | - db_branch.warehouse_url) |
236 | - mirrored_branch.pull(tree.branch) |
237 | |
238 | return db_branch |
239 | |
240 | @@ -396,229 +392,123 @@ |
241 | ['^WARNING .*/.*/.* is the official branch for .*/.*/.* but not ' |
242 | 'its sourcepackage$']) |
243 | |
244 | - def checkOneBranch_new_branch_missing(self, branch_type): |
245 | + def test_checkOneBranch_new_branch_missing(self): |
246 | # checkOneBranch returns False when there is no bzr branch for the |
247 | # database branch in the new distroseries. |
248 | - assert branch_type in ('hosted', 'mirrored') |
249 | db_branch = self.makeOfficialPackageBranch() |
250 | brancher = self.makeNewSeriesAndBrancher(db_branch.distroseries) |
251 | new_db_branch = brancher.makeOneNewBranch(db_branch) |
252 | - if branch_type == 'hosted': |
253 | - url = new_db_branch.getPullURL() |
254 | - else: |
255 | - url = new_db_branch.warehouse_url |
256 | + url = 'lp-internal:///' + new_db_branch.unique_name |
257 | get_transport(url).delete_tree('.bzr') |
258 | ok = brancher.checkOneBranch(db_branch) |
259 | self.assertFalse(ok) |
260 | # Deleting the new branch will break the old branch, as that's stacked |
261 | # on the new one. |
262 | self.assertLogMessages([ |
263 | - '^WARNING No bzr branch at new location lp-%s:///.*/.*/.*/.*$' |
264 | - % branch_type, |
265 | - '^WARNING No bzr branch at old location lp-%s:///.*/.*/.*/.*$' |
266 | - % branch_type, |
267 | + '^WARNING No bzr branch at new location ' |
268 | + 'lp-internal:///.*/.*/.*/.*$', |
269 | + '^WARNING No bzr branch at old location ' |
270 | + 'lp-internal:///.*/.*/.*/.*$', |
271 | ]) |
272 | |
273 | - def test_checkOneBranch_new_hosted_branch_missing(self): |
274 | - # checkOneBranch returns False when there is no bzr branch in the |
275 | - # hosted area for the database branch in the new distroseries. |
276 | - self.checkOneBranch_new_branch_missing('hosted') |
277 | - |
278 | - def test_checkOneBranch_new_mirrored_branch_missing(self): |
279 | - # checkOneBranch returns False when there is no bzr branch in the |
280 | - # mirrored area for the database branch in the new distroseries. |
281 | - self.checkOneBranch_new_branch_missing('mirrored') |
282 | - |
283 | - def checkOneBranch_old_branch_missing(self, branch_type): |
284 | + def test_checkOneBranch_old_branch_missing(self): |
285 | # checkOneBranch returns False when there is no bzr branchfor the |
286 | # database branch in old distroseries. |
287 | - assert branch_type in ('hosted', 'mirrored') |
288 | db_branch = self.makeOfficialPackageBranch() |
289 | brancher = self.makeNewSeriesAndBrancher(db_branch.distroseries) |
290 | brancher.makeOneNewBranch(db_branch) |
291 | - if branch_type == 'hosted': |
292 | - url = db_branch.getPullURL() |
293 | - else: |
294 | - url = db_branch.warehouse_url |
295 | + url = 'lp-internal:///' + db_branch.unique_name |
296 | get_transport(url).delete_tree('.bzr') |
297 | ok = brancher.checkOneBranch(db_branch) |
298 | self.assertFalse(ok) |
299 | self.assertLogMessages([ |
300 | - '^WARNING No bzr branch at old location lp-%s:///.*/.*/.*/.*$' |
301 | - % branch_type, |
302 | + '^WARNING No bzr branch at old location ' |
303 | + 'lp-internal:///.*/.*/.*/.*$' |
304 | ]) |
305 | |
306 | - def test_checkOneBranch_old_hosted_branch_missing(self): |
307 | - # checkOneBranch returns False when there is no bzr branch in the |
308 | - # hosted area for the database branch in old distroseries. |
309 | - self.checkOneBranch_old_branch_missing('hosted') |
310 | - |
311 | - def test_checkOneBranch_old_mirrored_branch_missing(self): |
312 | - # checkOneBranch returns False when there is no bzr branch in the |
313 | - # mirrored area for the database branch in old distroseries. |
314 | - self.checkOneBranch_old_branch_missing('mirrored') |
315 | - |
316 | - def checkOneBranch_new_stacked(self, branch_type): |
317 | + def test_checkOneBranch_new_stacked(self): |
318 | # checkOneBranch returns False when the bzr branch for the database |
319 | # branch in new distroseries is stacked. |
320 | - assert branch_type in ('hosted', 'mirrored') |
321 | db_branch = self.makeOfficialPackageBranch() |
322 | - b, _ = self.create_branch_and_tree( |
323 | - self.factory.getUniqueString(), hosted=(branch_type == 'hosted')) |
324 | + b, _ = self.create_branch_and_tree(self.factory.getUniqueString()) |
325 | brancher = self.makeNewSeriesAndBrancher(db_branch.distroseries) |
326 | new_db_branch = brancher.makeOneNewBranch(db_branch) |
327 | - if branch_type == 'hosted': |
328 | - url = new_db_branch.getPullURL() |
329 | - else: |
330 | - url = new_db_branch.warehouse_url |
331 | + url = 'lp-internal:///' + new_db_branch.unique_name |
332 | Branch.open(url).set_stacked_on_url('/' + b.unique_name) |
333 | ok = brancher.checkOneBranch(db_branch) |
334 | self.assertFalse(ok) |
335 | self.assertLogMessages([ |
336 | - '^WARNING New branch at lp-%s:///.*/.*/.*/.* is stacked on ' |
337 | - '/.*/.*/.*, should be unstacked.$' % branch_type, |
338 | + '^WARNING New branch at lp-internal:///.*/.*/.*/.* is stacked on ' |
339 | + '/.*/.*/.*, should be unstacked.$', |
340 | ]) |
341 | |
342 | - def test_checkOneBranch_new_hosted_stacked(self): |
343 | - # checkOneBranch returns False when the bzr branch in the hosted area |
344 | - # for the database branch in new distroseries is stacked. |
345 | - self.checkOneBranch_new_stacked('hosted') |
346 | - |
347 | - def test_checkOneBranch_new_mirrored_stacked(self): |
348 | - # checkOneBranch returns False when the bzr branch in the mirrored |
349 | - # area for the database branch in new distroseries is stacked. |
350 | - self.checkOneBranch_new_stacked('mirrored') |
351 | - |
352 | - def checkOneBranch_old_unstacked(self, branch_type): |
353 | + def test_checkOneBranch_old_unstacked(self): |
354 | # checkOneBranch returns False when the bzr branch for the database |
355 | # branch in old distroseries is not stacked. |
356 | - assert branch_type in ('hosted', 'mirrored') |
357 | db_branch = self.makeOfficialPackageBranch() |
358 | brancher = self.makeNewSeriesAndBrancher(db_branch.distroseries) |
359 | brancher.makeOneNewBranch(db_branch) |
360 | - if branch_type == 'hosted': |
361 | - url = db_branch.getPullURL() |
362 | - else: |
363 | - url = db_branch.warehouse_url |
364 | + url = 'lp-internal:///' + db_branch.unique_name |
365 | old_bzr_branch = Branch.open(url) |
366 | old_bzr_branch.set_stacked_on_url(None) |
367 | ok = brancher.checkOneBranch(db_branch) |
368 | self.assertLogMessages([ |
369 | - '^WARNING Old branch at lp-%s:///.*/.*/.*/.* is not stacked, ' |
370 | - 'should be stacked on /.*/.*/.*.$' % branch_type, |
371 | + '^WARNING Old branch at lp-internal:///.*/.*/.*/.* is not ' |
372 | + 'stacked, should be stacked on /.*/.*/.*.$', |
373 | '^.*has .* revisions.*$', |
374 | ]) |
375 | self.assertFalse(ok) |
376 | |
377 | - def test_checkOneBranch_old_hosted_unstacked(self): |
378 | - # checkOneBranch returns False when the bzr branch in the hosted area |
379 | - # for the database branch in old distroseries is not stacked. |
380 | - self.checkOneBranch_old_unstacked('hosted') |
381 | - |
382 | - def test_checkOneBranch_old_mirrored_unstacked(self): |
383 | - # checkOneBranch returns False when the bzr branch in the mirrored |
384 | - # area for the database branch in old distroseries is not stacked. |
385 | - self.checkOneBranch_old_unstacked('mirrored') |
386 | - |
387 | - def checkOneBranch_old_misstacked(self, branch_type): |
388 | + def test_checkOneBranch_old_misstacked(self): |
389 | # checkOneBranch returns False when the bzr branch for the database |
390 | # branch in old distroseries stacked on some other branch than the |
391 | # branch in the new distroseries. |
392 | - assert branch_type in ('hosted', 'mirrored') |
393 | db_branch = self.makeOfficialPackageBranch() |
394 | - b, _ = self.create_branch_and_tree( |
395 | - self.factory.getUniqueString(), hosted=(branch_type == 'hosted')) |
396 | + b, _ = self.create_branch_and_tree(self.factory.getUniqueString()) |
397 | brancher = self.makeNewSeriesAndBrancher(db_branch.distroseries) |
398 | brancher.makeOneNewBranch(db_branch) |
399 | - if branch_type == 'hosted': |
400 | - url = db_branch.getPullURL() |
401 | - else: |
402 | - url = db_branch.warehouse_url |
403 | + url = 'lp-internal:///' + db_branch.unique_name |
404 | Branch.open(url).set_stacked_on_url('/' + b.unique_name) |
405 | ok = brancher.checkOneBranch(db_branch) |
406 | self.assertLogMessages([ |
407 | - '^WARNING Old branch at lp-%s:///.*/.*/.*/.* is stacked on ' |
408 | - '/.*/.*/.*, should be stacked on /.*/.*/.*.$' % branch_type, |
409 | + '^WARNING Old branch at lp-internal:///.*/.*/.*/.* is stacked on ' |
410 | + '/.*/.*/.*, should be stacked on /.*/.*/.*.$', |
411 | ]) |
412 | self.assertFalse(ok) |
413 | |
414 | - def test_checkOneBranch_old_hosted_misstacked(self): |
415 | - # checkOneBranch returns False when the bzr branch in the hosted area |
416 | - # for the database branch in old distroseries stacked on some other |
417 | - # branch than the branch in the new distroseries. |
418 | - self.checkOneBranch_old_misstacked('hosted') |
419 | - |
420 | - def test_checkOneBranch_old_mirrored_misstacked(self): |
421 | - # checkOneBranch returns False when the bzr branch in the mirrored |
422 | - # area for the database branch in old distroseries stacked on some |
423 | - # other branch than the branch in the new distroseries. |
424 | - self.checkOneBranch_old_misstacked('mirrored') |
425 | - |
426 | - def checkOneBranch_old_has_revisions(self, branch_type): |
427 | + def test_checkOneBranch_old_has_revisions(self): |
428 | # checkOneBranch returns False when the bzr branch for the database |
429 | # branch in old distroseries has a repository that contains revisions. |
430 | - assert branch_type in ('hosted', 'mirrored') |
431 | db_branch = self.makeOfficialPackageBranch() |
432 | brancher = self.makeNewSeriesAndBrancher(db_branch.distroseries) |
433 | brancher.makeOneNewBranch(db_branch) |
434 | - if branch_type == 'hosted': |
435 | - url = db_branch.getPullURL() |
436 | - else: |
437 | - url = db_branch.warehouse_url |
438 | + url = 'lp-internal:///' + db_branch.unique_name |
439 | old_bzr_branch = Branch.open(url) |
440 | old_bzr_branch.create_checkout( |
441 | self.factory.getUniqueString()).commit('') |
442 | ok = brancher.checkOneBranch(db_branch) |
443 | self.assertLogMessages([ |
444 | - '^WARNING Repository at lp-%s:///.*/.*/.*/.* has 1 revisions.' |
445 | - % branch_type |
446 | + '^WARNING Repository at lp-internal:///.*/.*/.*/.* has 1 ' |
447 | + 'revisions.' |
448 | ]) |
449 | self.assertFalse(ok) |
450 | |
451 | - def test_checkOneBranch_old_hosted_has_revisions(self): |
452 | - # checkOneBranch returns False when the bzr branch in the hosted area |
453 | - # for the database branch in old distroseries has a repository that |
454 | - # contains revisions. |
455 | - self.checkOneBranch_old_has_revisions('hosted') |
456 | - |
457 | - def test_checkOneBranch_old_mirrored_has_revisions(self): |
458 | - # checkOneBranch returns False when the bzr branch in the mirrored |
459 | - # area for the database branch in old distroseries has a repository |
460 | - # that contains revisions. |
461 | - self.checkOneBranch_old_has_revisions('mirrored') |
462 | - |
463 | - def checkOneBranch_old_has_null_tip(self, branch_type): |
464 | + def test_checkOneBranch_old_has_null_tip(self): |
465 | # checkOneBranch returns False when the bzr branch for the database |
466 | # branch in old distroseries has tip revision of 'null:'. |
467 | - assert branch_type in ('hosted', 'mirrored') |
468 | db_branch = self.makeOfficialPackageBranch() |
469 | brancher = self.makeNewSeriesAndBrancher(db_branch.distroseries) |
470 | brancher.makeOneNewBranch(db_branch) |
471 | - if branch_type == 'hosted': |
472 | - url = db_branch.getPullURL() |
473 | - else: |
474 | - url = db_branch.warehouse_url |
475 | + url = 'lp-internal:///' + db_branch.unique_name |
476 | old_bzr_branch = Branch.open(url) |
477 | old_bzr_branch.set_last_revision_info(0, 'null:') |
478 | ok = brancher.checkOneBranch(db_branch) |
479 | self.assertLogMessages([ |
480 | - '^WARNING Old branch at lp-%s:///.*/.*/.*/.* has null tip ' |
481 | - 'revision.' % branch_type |
482 | + '^WARNING Old branch at lp-internal:///.*/.*/.*/.* has null tip ' |
483 | + 'revision.' |
484 | ]) |
485 | self.assertFalse(ok) |
486 | |
487 | - def test_checkOneBranch_old_hosted_has_null_tip(self): |
488 | - # checkOneBranch returns False when the bzr branch in the hosted area |
489 | - # for the database branch in old distroseries has tip revision of |
490 | - # 'null:'. |
491 | - self.checkOneBranch_old_has_null_tip('hosted') |
492 | - |
493 | - def test_checkOneBranch_old_mirrored_has_null_tip(self): |
494 | - # checkOneBranch returns False when the bzr branch in the mirrored |
495 | - # area for the database branch in old distroseries has tip revision of |
496 | - # 'null:'. |
497 | - self.checkOneBranch_old_has_null_tip('mirrored') |
498 | - |
499 | def runBranchDistroScript(self, args): |
500 | """Run the branch-distro.py script with the given arguments. |
501 | |
502 | |
503 | === modified file 'lib/lp/codehosting/vfs/branchfs.py' |
504 | --- lib/lp/codehosting/vfs/branchfs.py 2010-04-27 02:13:58 +0000 |
505 | +++ lib/lp/codehosting/vfs/branchfs.py 2010-04-27 02:14:19 +0000 |
506 | @@ -177,18 +177,25 @@ |
507 | 'lp-mirrored:///', codehosting_endpoint, branch_transport) |
508 | |
509 | |
510 | -def get_rw_server(): |
511 | +def get_rw_server(direct_database=False): |
512 | """Get a server that can write to the Launchpad branch vfs. |
513 | |
514 | You can only call this usefully on the codehost -- the transport this |
515 | server provides are backed onto file:/// URLs. |
516 | + |
517 | + :param direct_database: if True, use a server implementation that talks |
518 | + directly to the database. If False, the default, use a server |
519 | + implementation that talks to the internal XML-RPC server. |
520 | """ |
521 | - hosted_transport = get_chrooted_transport( |
522 | + transport = get_chrooted_transport( |
523 | config.codehosting.mirrored_branches_root, mkdir=True) |
524 | - proxy = xmlrpclib.ServerProxy(config.codehosting.codehosting_endpoint) |
525 | - codehosting_endpoint = BlockingProxy(proxy) |
526 | - return LaunchpadInternalServer( |
527 | - 'lp-internal:///', codehosting_endpoint, hosted_transport) |
528 | + if direct_database: |
529 | + return DirectDatabaseLaunchpadServer('lp-internal:///', transport) |
530 | + else: |
531 | + proxy = xmlrpclib.ServerProxy(config.codehosting.codehosting_endpoint) |
532 | + codehosting_endpoint = BlockingProxy(proxy) |
533 | + return LaunchpadInternalServer( |
534 | + 'lp-internal:///', codehosting_endpoint, transport) |
535 | |
536 | |
537 | def get_multi_server(write_hosted=False, write_mirrored=False, |
538 | |
539 | === modified file 'lib/lp/testing/__init__.py' |
540 | --- lib/lp/testing/__init__.py 2010-04-24 02:41:03 +0000 |
541 | +++ lib/lp/testing/__init__.py 2010-04-27 02:14:19 +0000 |
542 | @@ -84,7 +84,7 @@ |
543 | from canonical.launchpad.webapp.interaction import ANONYMOUS |
544 | from canonical.launchpad.webapp.interfaces import ILaunchBag |
545 | from canonical.launchpad.windmill.testing import constants |
546 | -from lp.codehosting.vfs import branch_id_to_path, get_multi_server |
547 | +from lp.codehosting.vfs import branch_id_to_path, get_rw_server |
548 | from lp.registry.interfaces.packaging import IPackagingUtil |
549 | # Import the login and logout functions here as it is a much better |
550 | # place to import them from in tests. |
551 | @@ -452,14 +452,12 @@ |
552 | branch_url, format=format) |
553 | |
554 | def create_branch_and_tree(self, tree_location=None, product=None, |
555 | - hosted=False, db_branch=None, format=None, |
556 | + db_branch=None, format=None, |
557 | **kwargs): |
558 | """Create a database branch, bzr branch and bzr checkout. |
559 | |
560 | :param tree_location: The path on disk to create the tree at. |
561 | :param product: The product to associate with the branch. |
562 | - :param hosted: If True, create in the hosted area. Otherwise, create |
563 | - in the mirrored area. |
564 | :param db_branch: If supplied, the database branch to use. |
565 | :param format: Override the default bzrdir format to create. |
566 | :return: a `Branch` and a workingtree. |
567 | @@ -469,10 +467,7 @@ |
568 | db_branch = self.factory.makeAnyBranch(**kwargs) |
569 | else: |
570 | db_branch = self.factory.makeProductBranch(product, **kwargs) |
571 | - if hosted: |
572 | - branch_url = db_branch.getPullURL() |
573 | - else: |
574 | - branch_url = db_branch.warehouse_url |
575 | + branch_url = 'lp-internal:///' + db_branch.unique_name |
576 | if self.real_bzr_server: |
577 | transaction.commit() |
578 | bzr_branch = self.createBranchAtURL(branch_url, format=format) |
579 | @@ -552,8 +547,7 @@ |
580 | self.useTempBzrHome() |
581 | self.real_bzr_server = real_server |
582 | if real_server: |
583 | - server = get_multi_server( |
584 | - write_hosted=True, write_mirrored=True, |
585 | + server = get_rw_server( |
586 | direct_database=direct_database) |
587 | server.start_server() |
588 | self.addCleanup(server.destroy) |
589 | |
590 | === modified file 'scripts/branch-distro.py' |
591 | --- scripts/branch-distro.py 2010-02-16 15:25:52 +0000 |
592 | +++ scripts/branch-distro.py 2010-04-27 02:14:19 +0000 |
593 | @@ -6,7 +6,7 @@ |
594 | import _pythonpath |
595 | |
596 | from lp.codehosting.branchdistro import DistroBrancher |
597 | -from lp.codehosting.vfs import get_multi_server |
598 | +from lp.codehosting.vfs import get_rw_server |
599 | from lp.services.scripts.base import LaunchpadScript, LaunchpadScriptFailure |
600 | |
601 | |
602 | @@ -24,8 +24,7 @@ |
603 | if len(self.args) != 3: |
604 | self.parser.error("Wrong number of arguments.") |
605 | brancher = DistroBrancher.fromNames(self.logger, *self.args) |
606 | - server = get_multi_server( |
607 | - write_mirrored=True, write_hosted=True, direct_database=True) |
608 | + server = get_rw_server(direct_database=True) |
609 | server.start_server() |
610 | try: |
611 | if self.options.check: |
Looks good.