~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_controldir/test_controldir.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:
393
393
            repo.set_make_working_trees(False)
394
394
            self.assertFalse(repo.make_working_trees())
395
395
 
396
 
        dir = tree.bzrdir
397
 
        a_dir = dir.clone(self.get_url('repo/a'))
398
 
        a_dir.open_branch()
 
396
        a_dir = tree.bzrdir.clone(self.get_url('repo/a'))
 
397
        a_branch = a_dir.open_branch()
 
398
        # If the new control dir actually uses the repository, it should
 
399
        # not have a working tree.
 
400
        if not a_branch.repository.has_same_location(repo):
 
401
            raise TestNotApplicable('new control dir does not use repository')
399
402
        self.assertRaises(errors.NoWorkingTree, a_dir.open_workingtree)
400
403
 
401
404
    def test_clone_respects_stacked(self):
406
409
                                                     stacked_on=branch.base)
407
410
        except (errors.UnstackableBranchFormat,
408
411
                errors.UnstackableRepositoryFormat):
409
 
            raise TestNotApplicable("branch or repository format do "
 
412
            raise TestNotApplicable("branch or repository format does "
410
413
                "not support stacking")
411
414
        self.assertEqual(child.open_branch().get_stacked_on_url(), branch.base)
412
415
 
462
465
            target.open_workingtree()
463
466
        except errors.NoWorkingTree:
464
467
            # Some bzrdirs can never have working trees.
465
 
            self.assertFalse(target._format.supports_workingtrees)
 
468
            repo = target.find_repository()
 
469
            self.assertFalse(repo.bzrdir._format.supports_workingtrees)
466
470
 
467
471
    def test_sprout_bzrdir_empty_under_shared_repo_force_new(self):
468
472
        # the force_new_repo parameter should force use of a new repo in an empty
1044
1048
            self.assertEqual(repo.bzrdir.root_transport.base,
1045
1049
                made_repo.bzrdir.root_transport.base)
1046
1050
 
1047
 
    def test_format_initialize_on_transport_ex_stacked_on(self):
1048
 
        if not self.bzrdir_format.is_initializable():
1049
 
            raise TestNotApplicable("format is not initializable")
1050
 
        # trunk is a stackable format.  Note that its in the same server area
1051
 
        # which is what launchpad does, but not sufficient to exercise the
1052
 
        # general case.
1053
 
        trunk = self.make_branch('trunk', format='1.9')
1054
 
        t = self.get_transport('stacked')
1055
 
        old_fmt = bzrdir.format_registry.make_bzrdir('pack-0.92')
1056
 
        repo_name = old_fmt.repository_format.network_name()
1057
 
        # Should end up with a 1.9 format (stackable)
1058
 
        repo, control = self.assertInitializeEx(t, need_meta=True,
1059
 
            repo_format_name=repo_name, stacked_on='../trunk',
1060
 
            stack_on_pwd=t.base)
1061
 
        self.assertLength(1, repo._fallback_repositories)
1062
 
 
1063
 
    def test_format_initialize_on_transport_ex_default_stack_on(self):
1064
 
        # When initialize_on_transport_ex uses a stacked-on branch because of
1065
 
        # a stacking policy on the target, the location of the fallback
1066
 
        # repository is the same as the external location of the stacked-on
1067
 
        # branch.
1068
 
        balloon = self.make_bzrdir('balloon')
1069
 
        if isinstance(balloon._format, bzrdir.BzrDirMetaFormat1):
1070
 
            stack_on = self.make_branch('stack-on', format='1.9')
1071
 
        else:
1072
 
            stack_on = self.make_branch('stack-on')
1073
 
        config = self.make_bzrdir('.').get_config()
1074
 
        try:
1075
 
            config.set_default_stack_on('stack-on')
1076
 
        except errors.BzrError:
1077
 
            raise TestNotApplicable('Only relevant for stackable formats.')
1078
 
        # Initialize a bzrdir subject to the policy.
1079
 
        t = self.get_transport('stacked')
1080
 
        repo_fmt = bzrdir.format_registry.make_bzrdir('1.9')
1081
 
        repo_name = repo_fmt.repository_format.network_name()
1082
 
        repo, control = self.assertInitializeEx(
1083
 
            t, need_meta=True, repo_format_name=repo_name, stacked_on=None)
1084
 
        # self.addCleanup(repo.unlock)
1085
 
        # There's one fallback repo, with a public location.
1086
 
        self.assertLength(1, repo._fallback_repositories)
1087
 
        fallback_repo = repo._fallback_repositories[0]
1088
 
        self.assertEqual(
1089
 
            stack_on.base, fallback_repo.bzrdir.root_transport.base)
1090
 
        # The bzrdir creates a branch in stacking-capable format.
1091
 
        new_branch = control.create_branch()
1092
 
        self.assertTrue(new_branch._format.supports_stacking())
1093
 
 
1094
1051
    def test_format_initialize_on_transport_ex_repo_fmt_name_None(self):
1095
1052
        t = self.get_transport('dir')
1096
1053
        repo, control = self.assertInitializeEx(t)
1107
1064
            repo_name = self.bzrdir_format.network_name()
1108
1065
        self.assertEqual(repo_name, repo._format.network_name())
1109
1066
 
1110
 
    def assertInitializeEx(self, t, need_meta=False, **kwargs):
 
1067
    def assertInitializeEx(self, t, **kwargs):
1111
1068
        """Execute initialize_on_transport_ex and check it succeeded correctly.
1112
1069
 
1113
1070
        This involves checking that the disk objects were created, open with
1130
1087
        self.assertIsInstance(control, controldir.ControlDir)
1131
1088
        opened = bzrdir.BzrDir.open(t.base)
1132
1089
        expected_format = self.bzrdir_format
1133
 
        if need_meta and expected_format.fixed_components:
1134
 
            # Pre-metadir formats change when we are making something that
1135
 
            # needs a metaformat, because clone is used for push.
1136
 
            expected_format = bzrdir.BzrDirMetaFormat1()
1137
1090
        if not isinstance(expected_format, RemoteBzrDirFormat):
1138
1091
            self.assertEqual(control._format.network_name(),
1139
1092
                expected_format.network_name())