Merge lp://staging/~thumper/launchpad/disable-import-auto-upgrade into lp://staging/launchpad

Proposed by Tim Penhey
Status: Merged
Merged at revision: not available
Proposed branch: lp://staging/~thumper/launchpad/disable-import-auto-upgrade
Merge into: lp://staging/launchpad
Diff against target: None lines
To merge this branch: bzr merge lp://staging/~thumper/launchpad/disable-import-auto-upgrade
Reviewer Review Type Date Requested Status
Michael Hudson-Doyle Approve
Review via email: mp+12017@code.staging.launchpad.net
To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) wrote :

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.

Revision history for this message
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.needs_format_conversion(format=required_format):
> + # XXX Tim Penhey 2009-09-18 bug abc Automatic upgrade of import
> + # branches disabled. Need an orderly upgrade process.
> + if False and bzr_dir.needs_format_conversion(format=required_format):

bug abc? :)

> - def test_pullUpgradesFormat(self):
> + def disabled_test_pullUpgradesFormat(self):

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://enigmail.mozdev.org

iEYEARECAAYFAkqy2hgACgkQeTTOPm7A7kgp/QCeJadBid7zcH9MqsnAu9bZD48x
FTMAnRdAc6/UyWWM9ErHv8GtfQGfMDlY
=ZF8d
-----END PGP SIGNATURE-----

review: Approve

Preview Diff

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