Merge lp:~thumper/launchpad/disable-import-auto-upgrade into lp:launchpad
- disable-import-auto-upgrade
- Merge into devel
Status: | Merged | ||||
---|---|---|---|---|---|
Merged at revision: | not available | ||||
Proposed branch: | lp:~thumper/launchpad/disable-import-auto-upgrade | ||||
Merge into: | lp:launchpad | ||||
Diff against target: | None lines | ||||
To merge this branch: | bzr merge lp:~thumper/launchpad/disable-import-auto-upgrade | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Michael Hudson-Doyle | Approve | ||
Review via email: mp+12017@code.launchpad.net |
Commit message
Description of the change
Tim Penhey (thumper) wrote : | # |
Michael Hudson-Doyle (mwhudson) wrote : | # |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Tim Penhey wrote:
> Tim Penhey has proposed merging lp:~thumper/launchpad/disable-import-auto-upgrade into lp:launchpad/devel.
>
> Requested reviews:
> Michael Hudson (mwhudson)
>
> This branch will include the approved bzr 2.0 changes :-(
Generally looks nice.
> Also, after moving the methods out of the puller/worker into bzrutils, I couldn't use them in the tests anyway as I didn't have two branches to compare to.
>
> This branch will disable the automatic upgrades of the import branches, and disables the tests for it too.
>
> The branch also adds a test and a fix for pushing divergant branches.
Two comments:
> - if bzr_dir.
> + # XXX Tim Penhey 2009-09-18 bug abc Automatic upgrade of import
> + # branches disabled. Need an orderly upgrade process.
> + if False and bzr_dir.
bug abc? :)
> - def test_pullUpgrad
> + def disabled_
Would be good to have a similar XXX here.
Otherwise, looks good.
review approve
Cheers,
mwh
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://
iEYEARECAAYFAkq
FTMAnRdAc6/
=ZF8d
-----END PGP SIGNATURE-----
Preview Diff
1 | === modified file 'lib/lp/codehosting/bzrutils.py' | |||
2 | --- lib/lp/codehosting/bzrutils.py 2009-07-17 00:26:05 +0000 | |||
3 | +++ lib/lp/codehosting/bzrutils.py 2009-09-18 00:08:40 +0000 | |||
4 | @@ -13,7 +13,9 @@ | |||
5 | 13 | 'DenyingServer', | 13 | 'DenyingServer', |
6 | 14 | 'ensure_base', | 14 | 'ensure_base', |
7 | 15 | 'get_branch_stacked_on_url', | 15 | 'get_branch_stacked_on_url', |
8 | 16 | 'get_vfs_format_classes', | ||
9 | 16 | 'HttpAsLocalTransport', | 17 | 'HttpAsLocalTransport', |
10 | 18 | 'identical_formats', | ||
11 | 17 | 'install_oops_handler', | 19 | 'install_oops_handler', |
12 | 18 | 'is_branch_stackable', | 20 | 'is_branch_stackable', |
13 | 19 | 'remove_exception_logging_hook', | 21 | 'remove_exception_logging_hook', |
14 | @@ -22,12 +24,11 @@ | |||
15 | 22 | import os | 24 | import os |
16 | 23 | import sys | 25 | import sys |
17 | 24 | 26 | ||
19 | 25 | from bzrlib import config | 27 | from bzrlib import config, trace |
20 | 26 | from bzrlib.errors import ( | 28 | from bzrlib.errors import ( |
21 | 27 | NoSuchFile, NotStacked, UnstackableBranchFormat, | 29 | NoSuchFile, NotStacked, UnstackableBranchFormat, |
22 | 28 | UnstackableRepositoryFormat) | 30 | UnstackableRepositoryFormat) |
25 | 29 | from bzrlib.remote import RemoteBzrDir | 31 | from bzrlib.remote import RemoteBranch, RemoteBzrDir, RemoteRepository |
24 | 30 | from bzrlib import trace | ||
26 | 31 | from bzrlib.transport import register_transport, unregister_transport | 32 | from bzrlib.transport import register_transport, unregister_transport |
27 | 32 | from bzrlib.transport.local import LocalTransport | 33 | from bzrlib.transport.local import LocalTransport |
28 | 33 | 34 | ||
29 | @@ -260,3 +261,34 @@ | |||
30 | 260 | """Prevent creation of transport for 'url'.""" | 261 | """Prevent creation of transport for 'url'.""" |
31 | 261 | raise AssertionError( | 262 | raise AssertionError( |
32 | 262 | "Creation of transport for %r is currently forbidden" % url) | 263 | "Creation of transport for %r is currently forbidden" % url) |
33 | 264 | |||
34 | 265 | |||
35 | 266 | def get_vfs_format_classes(branch): | ||
36 | 267 | """Return the vfs classes of the branch, repo and bzrdir formats. | ||
37 | 268 | |||
38 | 269 | 'vfs' here means that it will return the underlying format classes of a | ||
39 | 270 | remote branch. | ||
40 | 271 | """ | ||
41 | 272 | if isinstance(branch, RemoteBranch): | ||
42 | 273 | branch._ensure_real() | ||
43 | 274 | branch = branch._real_branch | ||
44 | 275 | repository = branch.repository | ||
45 | 276 | if isinstance(repository, RemoteRepository): | ||
46 | 277 | repository._ensure_real() | ||
47 | 278 | repository = repository._real_repository | ||
48 | 279 | bzrdir = branch.bzrdir | ||
49 | 280 | if isinstance(bzrdir, RemoteBzrDir): | ||
50 | 281 | bzrdir._ensure_real() | ||
51 | 282 | bzrdir = bzrdir._real_bzrdir | ||
52 | 283 | return ( | ||
53 | 284 | branch._format.__class__, | ||
54 | 285 | repository._format.__class__, | ||
55 | 286 | bzrdir._format.__class__, | ||
56 | 287 | ) | ||
57 | 288 | |||
58 | 289 | |||
59 | 290 | def identical_formats(branch_one, branch_two): | ||
60 | 291 | """Check if two branches have the same bzrdir, repo, and branch formats. | ||
61 | 292 | """ | ||
62 | 293 | return (get_vfs_format_classes(branch_one) == | ||
63 | 294 | get_vfs_format_classes(branch_two)) | ||
64 | 263 | 295 | ||
65 | === modified file 'lib/lp/codehosting/codeimport/tests/test_worker.py' | |||
66 | --- lib/lp/codehosting/codeimport/tests/test_worker.py 2009-07-17 00:26:05 +0000 | |||
67 | +++ lib/lp/codehosting/codeimport/tests/test_worker.py 2009-09-18 00:32:10 +0000 | |||
68 | @@ -108,7 +108,7 @@ | |||
69 | 108 | self.assertEqual( | 108 | self.assertEqual( |
70 | 109 | tree.branch.last_revision(), new_tree.branch.last_revision()) | 109 | tree.branch.last_revision(), new_tree.branch.last_revision()) |
71 | 110 | 110 | ||
73 | 111 | def test_pullUpgradesFormat(self): | 111 | def disabled_test_pullUpgradesFormat(self): |
74 | 112 | # A branch should always be in the most up-to-date format before a | 112 | # A branch should always be in the most up-to-date format before a |
75 | 113 | # pull is performed. | 113 | # pull is performed. |
76 | 114 | store = self.makeBranchStore() | 114 | store = self.makeBranchStore() |
77 | @@ -128,7 +128,7 @@ | |||
78 | 128 | self.assertEqual( | 128 | self.assertEqual( |
79 | 129 | default_format.get_branch_format(), new_branch._format) | 129 | default_format.get_branch_format(), new_branch._format) |
80 | 130 | 130 | ||
82 | 131 | def test_pullUpgradesFormatWithBackupDirPresent(self): | 131 | def disabled_test_pullUpgradesFormatWithBackupDirPresent(self): |
83 | 132 | # pull can upgrade the remote branch even if there is a backup.bzr | 132 | # pull can upgrade the remote branch even if there is a backup.bzr |
84 | 133 | # directory from a previous upgrade. | 133 | # directory from a previous upgrade. |
85 | 134 | store = self.makeBranchStore() | 134 | store = self.makeBranchStore() |
86 | @@ -162,6 +162,15 @@ | |||
87 | 162 | self.assertEqual( | 162 | self.assertEqual( |
88 | 163 | tree.branch.last_revision(), new_tree.branch.last_revision()) | 163 | tree.branch.last_revision(), new_tree.branch.last_revision()) |
89 | 164 | 164 | ||
90 | 165 | def test_push_divergant_branches(self): | ||
91 | 166 | # push() uses overwrite=True, so divergent branches (rebased) can be | ||
92 | 167 | # pushed. | ||
93 | 168 | store = self.makeBranchStore() | ||
94 | 169 | tree = create_branch_with_one_revision('original') | ||
95 | 170 | store.push(self.arbitrary_branch_id, tree, default_format) | ||
96 | 171 | tree = create_branch_with_one_revision('divergant') | ||
97 | 172 | store.push(self.arbitrary_branch_id, tree, default_format) | ||
98 | 173 | |||
99 | 165 | def fetchBranch(self, from_url, target_path): | 174 | def fetchBranch(self, from_url, target_path): |
100 | 166 | """Pull a branch from `from_url` to `target_path`. | 175 | """Pull a branch from `from_url` to `target_path`. |
101 | 167 | 176 | ||
102 | 168 | 177 | ||
103 | === modified file 'lib/lp/codehosting/codeimport/worker.py' | |||
104 | --- lib/lp/codehosting/codeimport/worker.py 2009-07-17 00:26:05 +0000 | |||
105 | +++ lib/lp/codehosting/codeimport/worker.py 2009-09-18 00:32:10 +0000 | |||
106 | @@ -62,7 +62,9 @@ | |||
107 | 62 | except NotBranchError: | 62 | except NotBranchError: |
108 | 63 | return BzrDir.create_standalone_workingtree( | 63 | return BzrDir.create_standalone_workingtree( |
109 | 64 | target_path, required_format) | 64 | target_path, required_format) |
111 | 65 | if bzr_dir.needs_format_conversion(format=required_format): | 65 | # XXX Tim Penhey 2009-09-18 bug abc Automatic upgrade of import |
112 | 66 | # branches disabled. Need an orderly upgrade process. | ||
113 | 67 | if False and bzr_dir.needs_format_conversion(format=required_format): | ||
114 | 66 | try: | 68 | try: |
115 | 67 | bzr_dir.root_transport.delete_tree('backup.bzr') | 69 | bzr_dir.root_transport.delete_tree('backup.bzr') |
116 | 68 | except NoSuchFile: | 70 | except NoSuchFile: |
117 | @@ -81,7 +83,7 @@ | |||
118 | 81 | except NotBranchError: | 83 | except NotBranchError: |
119 | 82 | branch_to = BzrDir.create_branch_and_repo( | 84 | branch_to = BzrDir.create_branch_and_repo( |
120 | 83 | target_url, format=required_format) | 85 | target_url, format=required_format) |
122 | 84 | branch_to.pull(branch_from) | 86 | branch_to.pull(branch_from, overwrite=True) |
123 | 85 | 87 | ||
124 | 86 | 88 | ||
125 | 87 | def get_default_bazaar_branch_store(): | 89 | def get_default_bazaar_branch_store(): |
126 | @@ -479,10 +481,6 @@ | |||
127 | 479 | class PullingImportWorker(ImportWorker): | 481 | class PullingImportWorker(ImportWorker): |
128 | 480 | """An import worker for imports that can be done by a bzr plugin.""" | 482 | """An import worker for imports that can be done by a bzr plugin.""" |
129 | 481 | 483 | ||
130 | 482 | # XXX 2009-03-05, MichaelHudson, bug=338061: There should be a way to find | ||
131 | 483 | # the 'default' rich-root format. | ||
132 | 484 | required_format = format_registry.get('1.9-rich-root')() | ||
133 | 485 | |||
134 | 486 | def _doImport(self): | 484 | def _doImport(self): |
135 | 487 | bazaar_tree = self.getBazaarWorkingTree() | 485 | bazaar_tree = self.getBazaarWorkingTree() |
136 | 488 | saved_factory = bzrlib.ui.ui_factory | 486 | saved_factory = bzrlib.ui.ui_factory |
137 | 489 | 487 | ||
138 | === modified file 'lib/lp/codehosting/puller/tests/test_acceptance.py' | |||
139 | --- lib/lp/codehosting/puller/tests/test_acceptance.py 2009-07-23 02:35:18 +0000 | |||
140 | +++ lib/lp/codehosting/puller/tests/test_acceptance.py 2009-09-17 05:07:50 +0000 | |||
141 | @@ -298,7 +298,7 @@ | |||
142 | 298 | elif branch_type == BranchType.MIRRORED: | 298 | elif branch_type == BranchType.MIRRORED: |
143 | 299 | # For mirrored branches, we serve the branch over HTTP, point the | 299 | # For mirrored branches, we serve the branch over HTTP, point the |
144 | 300 | # database branch at this HTTP server and call requestMirror() | 300 | # database branch at this HTTP server and call requestMirror() |
146 | 301 | self.setUpMirroredBranch(default_branch, format='1.6') | 301 | self.setUpMirroredBranch(default_branch) |
147 | 302 | transaction.commit() | 302 | transaction.commit() |
148 | 303 | else: | 303 | else: |
149 | 304 | raise AssertionError( | 304 | raise AssertionError( |
150 | @@ -315,7 +315,7 @@ | |||
151 | 315 | default_branch = self._makeDefaultStackedOnBranch() | 315 | default_branch = self._makeDefaultStackedOnBranch() |
152 | 316 | db_branch = self.factory.makeProductBranch( | 316 | db_branch = self.factory.makeProductBranch( |
153 | 317 | branch_type=BranchType.MIRRORED, product=default_branch.product) | 317 | branch_type=BranchType.MIRRORED, product=default_branch.product) |
155 | 318 | tree = self.setUpMirroredBranch(db_branch, format='1.6') | 318 | tree = self.setUpMirroredBranch(db_branch) |
156 | 319 | transaction.commit() | 319 | transaction.commit() |
157 | 320 | command, retcode, output, error = self.runPuller() | 320 | command, retcode, output, error = self.runPuller() |
158 | 321 | self.assertRanSuccessfully(command, retcode, output, error) | 321 | self.assertRanSuccessfully(command, retcode, output, error) |
159 | @@ -335,7 +335,7 @@ | |||
160 | 335 | db_branch = self.factory.makeProductBranch( | 335 | db_branch = self.factory.makeProductBranch( |
161 | 336 | branch_type=BranchType.HOSTED, product=default_branch.product) | 336 | branch_type=BranchType.HOSTED, product=default_branch.product) |
162 | 337 | transaction.commit() | 337 | transaction.commit() |
164 | 338 | self.pushBranch(db_branch, format='1.6') | 338 | self.pushBranch(db_branch) |
165 | 339 | command, retcode, output, error = self.runPuller() | 339 | command, retcode, output, error = self.runPuller() |
166 | 340 | self.assertRanSuccessfully(command, retcode, output, error) | 340 | self.assertRanSuccessfully(command, retcode, output, error) |
167 | 341 | mirrored_branch = self.assertMirrored(db_branch) | 341 | mirrored_branch = self.assertMirrored(db_branch) |
168 | @@ -358,7 +358,7 @@ | |||
169 | 358 | db_branch = self.factory.makeProductBranch( | 358 | db_branch = self.factory.makeProductBranch( |
170 | 359 | branch_type=BranchType.HOSTED, product=default_branch.product) | 359 | branch_type=BranchType.HOSTED, product=default_branch.product) |
171 | 360 | transaction.commit() | 360 | transaction.commit() |
173 | 361 | self.pushBranch(db_branch, format='1.6') | 361 | self.pushBranch(db_branch) |
174 | 362 | # Because Bazaar can't access branches over bzr+ssh in this test, we | 362 | # Because Bazaar can't access branches over bzr+ssh in this test, we |
175 | 363 | # cheat and set the stacking information directly. | 363 | # cheat and set the stacking information directly. |
176 | 364 | branch_config = TransportConfig( | 364 | branch_config = TransportConfig( |
177 | @@ -383,7 +383,7 @@ | |||
178 | 383 | db_branch = self.factory.makeProductBranch( | 383 | db_branch = self.factory.makeProductBranch( |
179 | 384 | branch_type=BranchType.MIRRORED, product=default_branch.product) | 384 | branch_type=BranchType.MIRRORED, product=default_branch.product) |
180 | 385 | 385 | ||
182 | 386 | tree = self.setUpMirroredBranch(db_branch, format='1.6') | 386 | tree = self.setUpMirroredBranch(db_branch) |
183 | 387 | transaction.commit() | 387 | transaction.commit() |
184 | 388 | command, retcode, output, error = self.runPuller() | 388 | command, retcode, output, error = self.runPuller() |
185 | 389 | self.assertRanSuccessfully(command, retcode, output, error) | 389 | self.assertRanSuccessfully(command, retcode, output, error) |
186 | 390 | 390 | ||
187 | === modified file 'lib/lp/codehosting/puller/tests/test_worker.py' | |||
188 | --- lib/lp/codehosting/puller/tests/test_worker.py 2009-09-08 23:12:55 +0000 | |||
189 | +++ lib/lp/codehosting/puller/tests/test_worker.py 2009-09-18 00:08:40 +0000 | |||
190 | @@ -16,17 +16,15 @@ | |||
191 | 16 | from bzrlib.bzrdir import BzrDir, BzrDirMetaFormat1 | 16 | from bzrlib.bzrdir import BzrDir, BzrDirMetaFormat1 |
192 | 17 | from bzrlib.errors import IncompatibleRepositories, NotBranchError, NotStacked | 17 | from bzrlib.errors import IncompatibleRepositories, NotBranchError, NotStacked |
193 | 18 | from bzrlib.tests.http_server import HttpServer | 18 | from bzrlib.tests.http_server import HttpServer |
194 | 19 | from bzrlib.remote import RemoteBranch | ||
195 | 20 | from bzrlib.repofmt.pack_repo import RepositoryFormatKnitPack1 | 19 | from bzrlib.repofmt.pack_repo import RepositoryFormatKnitPack1 |
196 | 21 | from bzrlib.revision import NULL_REVISION | 20 | from bzrlib.revision import NULL_REVISION |
197 | 22 | from bzrlib.smart import server | ||
198 | 23 | from bzrlib.tests import TestCaseInTempDir, TestCaseWithTransport | 21 | from bzrlib.tests import TestCaseInTempDir, TestCaseWithTransport |
199 | 24 | from bzrlib.transport import get_transport | 22 | from bzrlib.transport import get_transport |
200 | 25 | 23 | ||
201 | 26 | from lp.codehosting.bzrutils import ensure_base | 24 | from lp.codehosting.bzrutils import ensure_base |
202 | 27 | from lp.codehosting.puller.worker import ( | 25 | from lp.codehosting.puller.worker import ( |
203 | 28 | BranchLoopError, BranchMirrorer, BranchReferenceForbidden, | 26 | BranchLoopError, BranchMirrorer, BranchReferenceForbidden, |
205 | 29 | PullerWorkerProtocol, StackedOnBranchNotFound, get_vfs_format_classes, | 27 | PullerWorkerProtocol, StackedOnBranchNotFound, |
206 | 30 | install_worker_ui_factory, WORKER_ACTIVITY_NETWORK) | 28 | install_worker_ui_factory, WORKER_ACTIVITY_NETWORK) |
207 | 31 | from lp.codehosting.puller.tests import ( | 29 | from lp.codehosting.puller.tests import ( |
208 | 32 | AcceptAnythingPolicy, BlacklistPolicy, PullerWorkerMixin, WhitelistPolicy) | 30 | AcceptAnythingPolicy, BlacklistPolicy, PullerWorkerMixin, WhitelistPolicy) |
209 | @@ -56,37 +54,6 @@ | |||
210 | 56 | return strings | 54 | return strings |
211 | 57 | 55 | ||
212 | 58 | 56 | ||
213 | 59 | class TestGetVfsFormatClasses(TestCaseWithTransport): | ||
214 | 60 | """Tests for `lp.codehosting.puller.worker.get_vfs_format_classes`. | ||
215 | 61 | """ | ||
216 | 62 | |||
217 | 63 | def tearDown(self): | ||
218 | 64 | # This makes sure the connections held by the branches opened in the | ||
219 | 65 | # test are dropped, so the daemon threads serving those branches can | ||
220 | 66 | # exit. | ||
221 | 67 | gc.collect() | ||
222 | 68 | super(TestGetVfsFormatClasses, self).tearDown() | ||
223 | 69 | |||
224 | 70 | def test_get_vfs_format_classes(self): | ||
225 | 71 | # get_vfs_format_classes for a returns the underlying format classes | ||
226 | 72 | # of the branch, repo and bzrdir, even if the branch is a | ||
227 | 73 | # RemoteBranch. | ||
228 | 74 | vfs_branch = self.make_branch('.') | ||
229 | 75 | smart_server = server.SmartTCPServer_for_testing() | ||
230 | 76 | smart_server.setUp(self.get_vfs_only_server()) | ||
231 | 77 | self.addCleanup(smart_server.tearDown) | ||
232 | 78 | remote_branch = bzrlib.branch.Branch.open(smart_server.get_url()) | ||
233 | 79 | # Check that our set up worked: remote_branch is Remote and | ||
234 | 80 | # source_branch is not. | ||
235 | 81 | self.assertIsInstance(remote_branch, RemoteBranch) | ||
236 | 82 | self.failIf(isinstance(vfs_branch, RemoteBranch)) | ||
237 | 83 | # Now, get_vfs_format_classes on both branches returns the same format | ||
238 | 84 | # information. | ||
239 | 85 | self.assertEqual( | ||
240 | 86 | get_vfs_format_classes(vfs_branch), | ||
241 | 87 | get_vfs_format_classes(remote_branch)) | ||
242 | 88 | |||
243 | 89 | |||
244 | 90 | class PrearrangedStackedBranchPolicy(AcceptAnythingPolicy): | 57 | class PrearrangedStackedBranchPolicy(AcceptAnythingPolicy): |
245 | 91 | """A branch policy that returns a pre-configurable stack-on URL.""" | 58 | """A branch policy that returns a pre-configurable stack-on URL.""" |
246 | 92 | 59 | ||
247 | 93 | 60 | ||
248 | === modified file 'lib/lp/codehosting/puller/worker.py' | |||
249 | --- lib/lp/codehosting/puller/worker.py 2009-09-08 23:12:55 +0000 | |||
250 | +++ lib/lp/codehosting/puller/worker.py 2009-09-18 00:08:40 +0000 | |||
251 | @@ -12,18 +12,19 @@ | |||
252 | 12 | from bzrlib.bzrdir import BzrDir | 12 | from bzrlib.bzrdir import BzrDir |
253 | 13 | from bzrlib import errors | 13 | from bzrlib import errors |
254 | 14 | from bzrlib.plugins.loom.branch import LoomSupport | 14 | from bzrlib.plugins.loom.branch import LoomSupport |
255 | 15 | from bzrlib.remote import RemoteBranch, RemoteBzrDir, RemoteRepository | ||
256 | 16 | from bzrlib.transport import get_transport | 15 | from bzrlib.transport import get_transport |
257 | 17 | from bzrlib import urlutils | 16 | from bzrlib import urlutils |
258 | 18 | from bzrlib.ui import SilentUIFactory | 17 | from bzrlib.ui import SilentUIFactory |
259 | 19 | import bzrlib.ui | 18 | import bzrlib.ui |
260 | 20 | 19 | ||
261 | 21 | from canonical.config import config | 20 | from canonical.config import config |
262 | 21 | from canonical.launchpad.webapp import errorlog | ||
263 | 22 | |||
264 | 23 | from lp.codehosting.bzrutils import identical_formats | ||
265 | 24 | from lp.codehosting.puller import get_lock_id_for_branch_id | ||
266 | 22 | from lp.codehosting.vfs.branchfs import ( | 25 | from lp.codehosting.vfs.branchfs import ( |
267 | 23 | BadUrlLaunchpad, BadUrlScheme, BadUrlSsh, make_branch_mirrorer) | 26 | BadUrlLaunchpad, BadUrlScheme, BadUrlSsh, make_branch_mirrorer) |
268 | 24 | from lp.codehosting.puller import get_lock_id_for_branch_id | ||
269 | 25 | from lp.code.enums import BranchType | 27 | from lp.code.enums import BranchType |
270 | 26 | from canonical.launchpad.webapp import errorlog | ||
271 | 27 | from lazr.uri import InvalidURIError | 28 | from lazr.uri import InvalidURIError |
272 | 28 | 29 | ||
273 | 29 | 30 | ||
274 | @@ -119,37 +120,6 @@ | |||
275 | 119 | self.sendEvent('log', fmt % args) | 120 | self.sendEvent('log', fmt % args) |
276 | 120 | 121 | ||
277 | 121 | 122 | ||
278 | 122 | def get_vfs_format_classes(branch): | ||
279 | 123 | """Return the vfs classes of the branch, repo and bzrdir formats. | ||
280 | 124 | |||
281 | 125 | 'vfs' here means that it will return the underlying format classes of a | ||
282 | 126 | remote branch. | ||
283 | 127 | """ | ||
284 | 128 | if isinstance(branch, RemoteBranch): | ||
285 | 129 | branch._ensure_real() | ||
286 | 130 | branch = branch._real_branch | ||
287 | 131 | repository = branch.repository | ||
288 | 132 | if isinstance(repository, RemoteRepository): | ||
289 | 133 | repository._ensure_real() | ||
290 | 134 | repository = repository._real_repository | ||
291 | 135 | bzrdir = branch.bzrdir | ||
292 | 136 | if isinstance(bzrdir, RemoteBzrDir): | ||
293 | 137 | bzrdir._ensure_real() | ||
294 | 138 | bzrdir = bzrdir._real_bzrdir | ||
295 | 139 | return ( | ||
296 | 140 | branch._format.__class__, | ||
297 | 141 | repository._format.__class__, | ||
298 | 142 | bzrdir._format.__class__, | ||
299 | 143 | ) | ||
300 | 144 | |||
301 | 145 | |||
302 | 146 | def identical_formats(branch_one, branch_two): | ||
303 | 147 | """Check if two branches have the same bzrdir, repo, and branch formats. | ||
304 | 148 | """ | ||
305 | 149 | return (get_vfs_format_classes(branch_one) == | ||
306 | 150 | get_vfs_format_classes(branch_two)) | ||
307 | 151 | |||
308 | 152 | |||
309 | 153 | class BranchMirrorer(object): | 123 | class BranchMirrorer(object): |
310 | 154 | """A `BranchMirrorer` safely makes mirrors of branches. | 124 | """A `BranchMirrorer` safely makes mirrors of branches. |
311 | 155 | 125 | ||
312 | 156 | 126 | ||
313 | === modified file 'lib/lp/codehosting/scanner/tests/test_formats.py' | |||
314 | --- lib/lp/codehosting/scanner/tests/test_formats.py 2009-06-30 16:56:07 +0000 | |||
315 | +++ lib/lp/codehosting/scanner/tests/test_formats.py 2009-09-17 05:11:31 +0000 | |||
316 | @@ -12,9 +12,27 @@ | |||
317 | 12 | BranchFormat, ControlFormat, RepositoryFormat) | 12 | BranchFormat, ControlFormat, RepositoryFormat) |
318 | 13 | 13 | ||
319 | 14 | 14 | ||
320 | 15 | class TestScanFormat2a(BzrSyncTestCase): | ||
321 | 16 | """Test scanning of 2a repositories.""" | ||
322 | 17 | |||
323 | 18 | def testRecognize2a(self): | ||
324 | 19 | """Ensure scanner records correct formats for pack branches.""" | ||
325 | 20 | self.makeBzrSync(self.db_branch).syncBranchAndClose() | ||
326 | 21 | self.assertEqual(self.db_branch.branch_format, | ||
327 | 22 | BranchFormat.BZR_BRANCH_7) | ||
328 | 23 | self.assertEqual(self.db_branch.repository_format, | ||
329 | 24 | RepositoryFormat.BZR_CHK_2A) | ||
330 | 25 | self.assertEqual(self.db_branch.control_format, | ||
331 | 26 | ControlFormat.BZR_METADIR_1) | ||
332 | 27 | |||
333 | 28 | |||
334 | 15 | class TestScanFormatPack(BzrSyncTestCase): | 29 | class TestScanFormatPack(BzrSyncTestCase): |
335 | 16 | """Test scanning of pack-format repositories.""" | 30 | """Test scanning of pack-format repositories.""" |
336 | 17 | 31 | ||
337 | 32 | def makeBzrBranchAndTree(self, db_branch): | ||
338 | 33 | return BzrSyncTestCase.makeBzrBranchAndTree( | ||
339 | 34 | self, db_branch, 'pack-0.92') | ||
340 | 35 | |||
341 | 18 | def testRecognizePack(self): | 36 | def testRecognizePack(self): |
342 | 19 | """Ensure scanner records correct formats for pack branches.""" | 37 | """Ensure scanner records correct formats for pack branches.""" |
343 | 20 | self.makeBzrSync(self.db_branch).syncBranchAndClose() | 38 | self.makeBzrSync(self.db_branch).syncBranchAndClose() |
344 | 21 | 39 | ||
345 | === modified file 'lib/lp/codehosting/tests/test_bzrutils.py' | |||
346 | --- lib/lp/codehosting/tests/test_bzrutils.py 2009-07-17 00:26:05 +0000 | |||
347 | +++ lib/lp/codehosting/tests/test_bzrutils.py 2009-09-18 00:08:40 +0000 | |||
348 | @@ -8,10 +8,11 @@ | |||
349 | 8 | import gc | 8 | import gc |
350 | 9 | import sys | 9 | import sys |
351 | 10 | 10 | ||
353 | 11 | from bzrlib import errors | 11 | from bzrlib import errors, trace |
354 | 12 | from bzrlib.branch import Branch | 12 | from bzrlib.branch import Branch |
355 | 13 | from bzrlib.bzrdir import format_registry | 13 | from bzrlib.bzrdir import format_registry |
357 | 14 | from bzrlib import trace | 14 | from bzrlib.remote import RemoteBranch |
358 | 15 | from bzrlib.smart import server | ||
359 | 15 | from bzrlib.tests import ( | 16 | from bzrlib.tests import ( |
360 | 16 | multiply_tests, TestCase, TestCaseWithTransport, TestLoader, | 17 | multiply_tests, TestCase, TestCaseWithTransport, TestLoader, |
361 | 17 | TestNotApplicable) | 18 | TestNotApplicable) |
362 | @@ -20,9 +21,11 @@ | |||
363 | 20 | except ImportError: | 21 | except ImportError: |
364 | 21 | from bzrlib.tests.branch_implementations import ( | 22 | from bzrlib.tests.branch_implementations import ( |
365 | 22 | TestCaseWithBzrDir, branch_scenarios) | 23 | TestCaseWithBzrDir, branch_scenarios) |
366 | 24 | |||
367 | 23 | from lp.codehosting.bzrutils import ( | 25 | from lp.codehosting.bzrutils import ( |
368 | 24 | add_exception_logging_hook, DenyingServer, get_branch_stacked_on_url, | 26 | add_exception_logging_hook, DenyingServer, get_branch_stacked_on_url, |
370 | 25 | is_branch_stackable, remove_exception_logging_hook) | 27 | get_vfs_format_classes, is_branch_stackable, |
371 | 28 | remove_exception_logging_hook) | ||
372 | 26 | from lp.codehosting.tests.helpers import TestResultWrapper | 29 | from lp.codehosting.tests.helpers import TestResultWrapper |
373 | 27 | 30 | ||
374 | 28 | 31 | ||
375 | @@ -168,6 +171,37 @@ | |||
376 | 168 | self.assertEqual([], exceptions) | 171 | self.assertEqual([], exceptions) |
377 | 169 | 172 | ||
378 | 170 | 173 | ||
379 | 174 | class TestGetVfsFormatClasses(TestCaseWithTransport): | ||
380 | 175 | """Tests for `lp.codehosting.bzrutils.get_vfs_format_classes`. | ||
381 | 176 | """ | ||
382 | 177 | |||
383 | 178 | def tearDown(self): | ||
384 | 179 | # This makes sure the connections held by the branches opened in the | ||
385 | 180 | # test are dropped, so the daemon threads serving those branches can | ||
386 | 181 | # exit. | ||
387 | 182 | gc.collect() | ||
388 | 183 | super(TestGetVfsFormatClasses, self).tearDown() | ||
389 | 184 | |||
390 | 185 | def test_get_vfs_format_classes(self): | ||
391 | 186 | # get_vfs_format_classes for a returns the underlying format classes | ||
392 | 187 | # of the branch, repo and bzrdir, even if the branch is a | ||
393 | 188 | # RemoteBranch. | ||
394 | 189 | vfs_branch = self.make_branch('.') | ||
395 | 190 | smart_server = server.SmartTCPServer_for_testing() | ||
396 | 191 | smart_server.setUp(self.get_vfs_only_server()) | ||
397 | 192 | self.addCleanup(smart_server.tearDown) | ||
398 | 193 | remote_branch = Branch.open(smart_server.get_url()) | ||
399 | 194 | # Check that our set up worked: remote_branch is Remote and | ||
400 | 195 | # source_branch is not. | ||
401 | 196 | self.assertIsInstance(remote_branch, RemoteBranch) | ||
402 | 197 | self.failIf(isinstance(vfs_branch, RemoteBranch)) | ||
403 | 198 | # Now, get_vfs_format_classes on both branches returns the same format | ||
404 | 199 | # information. | ||
405 | 200 | self.assertEqual( | ||
406 | 201 | get_vfs_format_classes(vfs_branch), | ||
407 | 202 | get_vfs_format_classes(remote_branch)) | ||
408 | 203 | |||
409 | 204 | |||
410 | 171 | def load_tests(basic_tests, module, loader): | 205 | def load_tests(basic_tests, module, loader): |
411 | 172 | """Parametrize the tests of get_branch_stacked_on_url by branch format.""" | 206 | """Parametrize the tests of get_branch_stacked_on_url by branch format.""" |
412 | 173 | result = loader.suiteClass() | 207 | result = loader.suiteClass() |
413 | @@ -181,6 +215,7 @@ | |||
414 | 181 | result.addTests(loader.loadTestsFromTestCase(TestIsBranchStackable)) | 215 | result.addTests(loader.loadTestsFromTestCase(TestIsBranchStackable)) |
415 | 182 | result.addTests(loader.loadTestsFromTestCase(TestDenyingServer)) | 216 | result.addTests(loader.loadTestsFromTestCase(TestDenyingServer)) |
416 | 183 | result.addTests(loader.loadTestsFromTestCase(TestExceptionLoggingHooks)) | 217 | result.addTests(loader.loadTestsFromTestCase(TestExceptionLoggingHooks)) |
417 | 218 | result.addTests(loader.loadTestsFromTestCase(TestGetVfsFormatClasses)) | ||
418 | 184 | return result | 219 | return result |
419 | 185 | 220 | ||
420 | 186 | 221 | ||
421 | 187 | 222 | ||
422 | === renamed file 'lib/lp/codehosting/puller/tests/test_format_comparison.py' => 'lib/lp/codehosting/tests/test_format_comparison.py' | |||
423 | --- lib/lp/codehosting/puller/tests/test_format_comparison.py 2009-06-25 04:06:00 +0000 | |||
424 | +++ lib/lp/codehosting/tests/test_format_comparison.py 2009-09-18 00:08:40 +0000 | |||
425 | @@ -7,7 +7,7 @@ | |||
426 | 7 | 7 | ||
427 | 8 | import unittest | 8 | import unittest |
428 | 9 | 9 | ||
430 | 10 | from lp.codehosting.puller import worker | 10 | from lp.codehosting.bzrutils import identical_formats |
431 | 11 | 11 | ||
432 | 12 | 12 | ||
433 | 13 | # Define a bunch of different fake format classes to pass to identical_formats | 13 | # Define a bunch of different fake format classes to pass to identical_formats |
434 | @@ -52,7 +52,7 @@ | |||
435 | 52 | # identical_formats should return True when both branches have the same | 52 | # identical_formats should return True when both branches have the same |
436 | 53 | # bzrdir, repository, and branch formats. | 53 | # bzrdir, repository, and branch formats. |
437 | 54 | self.failUnless( | 54 | self.failUnless( |
439 | 55 | worker.identical_formats( | 55 | identical_formats( |
440 | 56 | StubBranch(BzrDirFormatA(), RepoFormatA(), BranchFormatA()), | 56 | StubBranch(BzrDirFormatA(), RepoFormatA(), BranchFormatA()), |
441 | 57 | StubBranch(BzrDirFormatA(), RepoFormatA(), BranchFormatA()))) | 57 | StubBranch(BzrDirFormatA(), RepoFormatA(), BranchFormatA()))) |
442 | 58 | 58 | ||
443 | @@ -60,7 +60,7 @@ | |||
444 | 60 | # identical_formats should return False when both branches have the | 60 | # identical_formats should return False when both branches have the |
445 | 61 | # different bzrdir formats. | 61 | # different bzrdir formats. |
446 | 62 | self.failIf( | 62 | self.failIf( |
448 | 63 | worker.identical_formats( | 63 | identical_formats( |
449 | 64 | StubBranch(BzrDirFormatA(), RepoFormatA(), BranchFormatA()), | 64 | StubBranch(BzrDirFormatA(), RepoFormatA(), BranchFormatA()), |
450 | 65 | StubBranch(BzrDirFormatB(), RepoFormatA(), BranchFormatA()))) | 65 | StubBranch(BzrDirFormatB(), RepoFormatA(), BranchFormatA()))) |
451 | 66 | 66 | ||
452 | @@ -68,7 +68,7 @@ | |||
453 | 68 | # identical_formats should return False when both branches have the | 68 | # identical_formats should return False when both branches have the |
454 | 69 | # different repository formats. | 69 | # different repository formats. |
455 | 70 | self.failIf( | 70 | self.failIf( |
457 | 71 | worker.identical_formats( | 71 | identical_formats( |
458 | 72 | StubBranch(BzrDirFormatA(), RepoFormatA(), BranchFormatA()), | 72 | StubBranch(BzrDirFormatA(), RepoFormatA(), BranchFormatA()), |
459 | 73 | StubBranch(BzrDirFormatA(), RepoFormatB(), BranchFormatA()))) | 73 | StubBranch(BzrDirFormatA(), RepoFormatB(), BranchFormatA()))) |
460 | 74 | 74 | ||
461 | @@ -76,11 +76,10 @@ | |||
462 | 76 | # identical_formats should return False when both branches have the | 76 | # identical_formats should return False when both branches have the |
463 | 77 | # different branch formats. | 77 | # different branch formats. |
464 | 78 | self.failIf( | 78 | self.failIf( |
466 | 79 | worker.identical_formats( | 79 | identical_formats( |
467 | 80 | StubBranch(BzrDirFormatA(), RepoFormatA(), BranchFormatA()), | 80 | StubBranch(BzrDirFormatA(), RepoFormatA(), BranchFormatA()), |
468 | 81 | StubBranch(BzrDirFormatA(), RepoFormatA(), BranchFormatB()))) | 81 | StubBranch(BzrDirFormatA(), RepoFormatA(), BranchFormatB()))) |
469 | 82 | 82 | ||
470 | 83 | 83 | ||
471 | 84 | def test_suite(): | 84 | def test_suite(): |
472 | 85 | return unittest.TestLoader().loadTestsFromName(__name__) | 85 | return unittest.TestLoader().loadTestsFromName(__name__) |
473 | 86 | |||
474 | 87 | 86 | ||
475 | === modified file 'versions.cfg' | |||
476 | --- versions.cfg 2009-09-14 21:54:37 +0000 | |||
477 | +++ versions.cfg 2009-09-17 05:07:28 +0000 | |||
478 | @@ -3,7 +3,7 @@ | |||
479 | 3 | 3 | ||
480 | 4 | [versions] | 4 | [versions] |
481 | 5 | # Alphabetical, case-insensitive, please! :-) | 5 | # Alphabetical, case-insensitive, please! :-) |
483 | 6 | bzr = 1.18 | 6 | bzr = 2.0rc2 |
484 | 7 | chameleon.core = 1.0b35 | 7 | chameleon.core = 1.0b35 |
485 | 8 | chameleon.zpt = 1.0b17 | 8 | chameleon.zpt = 1.0b17 |
486 | 9 | ClientForm = 0.2.10 | 9 | ClientForm = 0.2.10 |
This branch will include the approved bzr 2.0 changes :-(
Also, after moving the methods out of the puller/worker into bzrutils, I couldn't use them in the tests anyway as I didn't have two branches to compare to.
This branch will disable the automatic upgrades of the import branches, and disables the tests for it too.
The branch also adds a test and a fix for pushing divergant branches.