513
513
# Clone source into directory
514
514
target = source_bzrdir.clone(self.get_url('parent/target'))
516
def test_format_initialize_on_transport_ex_stacked_on(self):
517
# trunk is a stackable format. Note that its in the same server area
518
# which is what launchpad does, but not sufficient to exercise the
520
trunk = self.make_branch('trunk', format='1.9')
521
t = self.get_transport('stacked')
522
old_fmt = bzrdir.format_registry.make_bzrdir('pack-0.92')
523
repo_name = old_fmt.repository_format.network_name()
524
# Should end up with a 1.9 format (stackable)
525
repo, control, require_stacking, repo_policy = \
526
old_fmt.initialize_on_transport_ex(t,
527
repo_format_name=repo_name, stacked_on='../trunk',
530
# Repositories are open write-locked
531
self.assertTrue(repo.is_write_locked())
532
self.addCleanup(repo.unlock)
534
repo = control.open_repository()
535
self.assertIsInstance(control, bzrdir.BzrDir)
536
opened = bzrdir.BzrDir.open(t.base)
537
if not isinstance(old_fmt, remote.RemoteBzrDirFormat):
538
self.assertEqual(control._format.network_name(),
539
old_fmt.network_name())
540
self.assertEqual(control._format.network_name(),
541
opened._format.network_name())
542
self.assertEqual(control.__class__, opened.__class__)
543
self.assertLength(1, repo._fallback_repositories)
516
545
def test_sprout_obeys_stacking_policy(self):
517
546
child_branch, new_child_transport = self.prepare_default_stacking()
518
547
new_child = child_branch.bzrdir.sprout(new_child_transport.base)
1323
1352
self.assertEqual('fail', err._preformatted_string)
1325
1354
def test_post_repo_init(self):
1326
from bzrlib.bzrdir import RepoInitHookParams
1355
from bzrlib.controldir import RepoInitHookParams
1328
1357
bzrdir.BzrDir.hooks.install_named_hook('post_repo_init',
1329
1358
calls.append, None)
1368
1397
self._transport.put_bytes("a.~1~", "some content")
1369
1398
self.assertEqual("a.~2~", self._bzrdir._available_backup_name("a"))
1401
class TestMeta1DirColoFormat(TestCaseWithTransport):
1402
"""Tests specific to the meta1 dir with colocated branches format."""
1404
def test_supports_colo(self):
1405
format = bzrdir.BzrDirMetaFormat1Colo()
1406
self.assertTrue(format.colocated_branches)
1408
def test_upgrade_from_2a(self):
1409
tree = self.make_branch_and_tree('.', format='2a')
1410
format = bzrdir.BzrDirMetaFormat1Colo()
1411
self.assertTrue(tree.bzrdir.needs_format_conversion(format))
1412
converter = tree.bzrdir._format.get_converter(format)
1413
result = converter.convert(tree.bzrdir, None)
1414
self.assertIsInstance(result._format, bzrdir.BzrDirMetaFormat1Colo)
1415
self.assertFalse(result.needs_format_conversion(format))
1417
def test_downgrade_to_2a(self):
1418
tree = self.make_branch_and_tree('.', format='development-colo')
1419
format = bzrdir.BzrDirMetaFormat1()
1420
self.assertTrue(tree.bzrdir.needs_format_conversion(format))
1421
converter = tree.bzrdir._format.get_converter(format)
1422
result = converter.convert(tree.bzrdir, None)
1423
self.assertIsInstance(result._format, bzrdir.BzrDirMetaFormat1)
1424
self.assertFalse(result.needs_format_conversion(format))
1426
def test_downgrade_to_2a_too_many_branches(self):
1427
tree = self.make_branch_and_tree('.', format='development-colo')
1428
tree.bzrdir.create_branch(name="another-colocated-branch")
1429
converter = tree.bzrdir._format.get_converter(
1430
bzrdir.BzrDirMetaFormat1())
1431
self.assertRaises(errors.BzrError, converter.convert, tree.bzrdir,