~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_bzrdir.py

  • Committer: Shannon Weyrick
  • Date: 2011-11-04 13:40:04 UTC
  • mfrom: (6238 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6256.
  • Revision ID: weyrick@mozek.us-20111104134004-033t2wqhc3ydzm0a
Merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
513
513
        # Clone source into directory
514
514
        target = source_bzrdir.clone(self.get_url('parent/target'))
515
515
 
 
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
 
519
        # general case.
 
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',
 
528
                    stack_on_pwd=t.base)
 
529
        if repo is not None:
 
530
            # Repositories are open write-locked
 
531
            self.assertTrue(repo.is_write_locked())
 
532
            self.addCleanup(repo.unlock)
 
533
        else:
 
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)
 
544
 
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)
1324
1353
 
1325
1354
    def test_post_repo_init(self):
1326
 
        from bzrlib.bzrdir import RepoInitHookParams
 
1355
        from bzrlib.controldir import RepoInitHookParams
1327
1356
        calls = []
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"))
1370
1399
 
 
1400
 
 
1401
class TestMeta1DirColoFormat(TestCaseWithTransport):
 
1402
    """Tests specific to the meta1 dir with colocated branches format."""
 
1403
 
 
1404
    def test_supports_colo(self):
 
1405
        format = bzrdir.BzrDirMetaFormat1Colo()
 
1406
        self.assertTrue(format.colocated_branches)
 
1407
 
 
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))
 
1416
 
 
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))
 
1425
 
 
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,
 
1432
            None)