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