~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/per_controldir/test_controldir.py

  • Committer: Vincent Ladeuil
  • Date: 2012-03-08 18:30:33 UTC
  • mfrom: (6487 +trunk)
  • mto: This revision was merged to the branch mainline in revision 6488.
  • Revision ID: v.ladeuil+lp@free.fr-20120308183033-bccqnbr1tpozs711
Merge bzr.dev resolving conflicts

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
import bzrlib.branch
22
22
from bzrlib import (
23
 
    bzrdir,
 
23
    bzrdir as _mod_bzrdir,
24
24
    check,
25
25
    controldir,
26
26
    errors,
27
27
    gpg,
28
28
    osutils,
 
29
    revision as _mod_revision,
29
30
    transport,
30
31
    ui,
31
32
    urlutils,
32
33
    workingtree,
33
34
    )
34
 
import bzrlib.revision
35
35
from bzrlib.tests import (
36
36
    fixtures,
37
37
    ChrootedTestCase,
124
124
        dir.create_repository()
125
125
        dir.create_branch()
126
126
        try:
127
 
            wt = dir.create_workingtree(revision_id=bzrlib.revision.NULL_REVISION)
 
127
            wt = dir.create_workingtree(revision_id=_mod_revision.NULL_REVISION)
128
128
        except (errors.NotLocalUrl, errors.UnsupportedOperation):
129
129
            raise TestSkipped("cannot make working tree with transport %r"
130
130
                              % dir.transport)
186
186
        e.g. NotLocalUrl) if there is no working tree.
187
187
        """
188
188
        dir = self.make_bzrdir('source')
189
 
        vfs_dir = bzrdir.BzrDir.open(self.get_vfs_only_url('source'))
 
189
        vfs_dir = controldir.ControlDir.open(self.get_vfs_only_url('source'))
190
190
        if vfs_dir.has_workingtree():
191
191
            # This ControlDir format doesn't support ControlDirs without
192
192
            # working trees, so this test is irrelevant.
232
232
        tree.add('foo')
233
233
        tree.commit('revision 1', rev_id='1')
234
234
        tree.bzrdir.open_branch().generate_revision_history(
235
 
            bzrlib.revision.NULL_REVISION)
 
235
            _mod_revision.NULL_REVISION)
236
236
        tree.set_parent_trees([])
237
237
        tree.commit('revision 2', rev_id='2')
238
238
        # Copy the content (i.e. revisions) from the 'commit_tree' branch's
265
265
        tree.add('foo')
266
266
        tree.commit('revision 1', rev_id='1')
267
267
        tree.branch.bzrdir.open_branch().generate_revision_history(
268
 
            bzrlib.revision.NULL_REVISION)
 
268
            _mod_revision.NULL_REVISION)
269
269
        tree.set_parent_trees([])
270
270
        tree.commit('revision 2', rev_id='2')
271
271
        tree.branch.repository.copy_content_into(shared_repo)
293
293
        tree.add('foo')
294
294
        tree.commit('revision 1', rev_id='1')
295
295
        tree.branch.bzrdir.open_branch().generate_revision_history(
296
 
            bzrlib.revision.NULL_REVISION)
 
296
            _mod_revision.NULL_REVISION)
297
297
        tree.set_parent_trees([])
298
298
        tree.commit('revision 2', rev_id='2')
299
299
        source = self.make_repository('source')
365
365
        self.assertEqual('1', target.open_branch().last_revision())
366
366
 
367
367
    def test_clone_on_transport_preserves_repo_format(self):
368
 
        if self.bzrdir_format == bzrdir.format_registry.make_bzrdir('default'):
 
368
        if self.bzrdir_format == controldir.format_registry.make_bzrdir('default'):
369
369
            format = 'knit'
370
370
        else:
371
371
            format = None
552
552
        tree.add('foo')
553
553
        tree.commit('revision 1', rev_id='1')
554
554
        tree.bzrdir.open_branch().generate_revision_history(
555
 
            bzrlib.revision.NULL_REVISION)
 
555
            _mod_revision.NULL_REVISION)
556
556
        tree.set_parent_trees([])
557
557
        tree.commit('revision 2', rev_id='2')
558
558
        source = self.make_repository('source')
581
581
        tree.add('foo')
582
582
        tree.commit('revision 1', rev_id='1')
583
583
        tree.bzrdir.open_branch().generate_revision_history(
584
 
            bzrlib.revision.NULL_REVISION)
 
584
            _mod_revision.NULL_REVISION)
585
585
        tree.set_parent_trees([])
586
586
        tree.commit('revision 2', rev_id='2')
587
587
        tree.branch.repository.copy_content_into(shared_repo)
606
606
        tree.add('foo')
607
607
        tree.commit('revision 1', rev_id='1')
608
608
        tree.bzrdir.open_branch().generate_revision_history(
609
 
            bzrlib.revision.NULL_REVISION)
 
609
            _mod_revision.NULL_REVISION)
610
610
        tree.set_parent_trees([])
611
611
        tree.commit('revision 2', rev_id='2')
612
612
        tree.branch.repository.copy_content_into(shared_repo)
634
634
        tree.add('foo')
635
635
        tree.commit('revision 1', rev_id='1')
636
636
        tree.bzrdir.open_branch().generate_revision_history(
637
 
            bzrlib.revision.NULL_REVISION)
 
637
            _mod_revision.NULL_REVISION)
638
638
        tree.set_parent_trees([])
639
639
        tree.commit('revision 2', rev_id='2')
640
640
        source = self.make_repository('source')
661
661
        tree.add('foo')
662
662
        tree.commit('revision 1', rev_id='1')
663
663
        br = tree.bzrdir.open_branch()
664
 
        br.set_last_revision_info(0, bzrlib.revision.NULL_REVISION)
 
664
        br.set_last_revision_info(0, _mod_revision.NULL_REVISION)
665
665
        tree.set_parent_trees([])
666
666
        tree.commit('revision 2', rev_id='2')
667
667
        source = self.make_repository('source')
1048
1048
        self.assertEqual(self.bzrdir_format,
1049
1049
                         controldir.ControlDirFormat.find_format(readonly_t))
1050
1050
        direct_opened_dir = self.bzrdir_format.open(readonly_t)
1051
 
        opened_dir = bzrdir.BzrDir.open(t.base)
 
1051
        opened_dir = controldir.ControlDir.open(t.base)
1052
1052
        self.assertEqual(made_control._format,
1053
1053
                         opened_dir._format)
1054
1054
        self.assertEqual(direct_opened_dir._format,
1086
1086
 
1087
1087
    def test_format_initialize_on_transport_ex_force_new_repo_True(self):
1088
1088
        t = self.get_transport('repo')
1089
 
        repo_fmt = bzrdir.format_registry.make_bzrdir('1.9')
 
1089
        repo_fmt = controldir.format_registry.make_bzrdir('1.9')
1090
1090
        repo_name = repo_fmt.repository_format.network_name()
1091
1091
        repo = repo_fmt.initialize_on_transport_ex(t,
1092
1092
            repo_format_name=repo_name, shared_repo=True)[0]
1097
1097
 
1098
1098
    def test_format_initialize_on_transport_ex_force_new_repo_False(self):
1099
1099
        t = self.get_transport('repo')
1100
 
        repo_fmt = bzrdir.format_registry.make_bzrdir('1.9')
 
1100
        repo_fmt = controldir.format_registry.make_bzrdir('1.9')
1101
1101
        repo_name = repo_fmt.repository_format.network_name()
1102
1102
        repo = repo_fmt.initialize_on_transport_ex(t,
1103
1103
            repo_format_name=repo_name, shared_repo=True)[0]
1115
1115
    def test_format_initialize_on_transport_ex_repo_fmt_name_followed(self):
1116
1116
        t = self.get_transport('dir')
1117
1117
        # 1.6 is likely to never be default
1118
 
        fmt = bzrdir.format_registry.make_bzrdir('1.6')
 
1118
        fmt = controldir.format_registry.make_bzrdir('1.6')
1119
1119
        repo_name = fmt.repository_format.network_name()
1120
1120
        repo, control = self.assertInitializeEx(t, repo_format_name=repo_name)
1121
1121
        if self.bzrdir_format.fixed_components:
1144
1144
            self.assertTrue(repo.is_write_locked())
1145
1145
            self.addCleanup(repo.unlock)
1146
1146
        self.assertIsInstance(control, controldir.ControlDir)
1147
 
        opened = bzrdir.BzrDir.open(t.base)
 
1147
        opened = controldir.ControlDir.open(t.base)
1148
1148
        expected_format = self.bzrdir_format
1149
1149
        if not isinstance(expected_format, RemoteBzrDirFormat):
1150
1150
            self.assertEqual(control._format.network_name(),
1383
1383
        except (errors.NotLocalUrl, errors.UnsupportedOperation):
1384
1384
            raise TestSkipped("Can't initialize %r on transport %r"
1385
1385
                              % (self.bzrdir_format, t))
1386
 
        dir = bzrdir.BzrDir.open(t.base+",branch=foo")
 
1386
        dir = controldir.ControlDir.open(t.base+",branch=foo")
1387
1387
        self.assertEquals({"branch": "foo"},
1388
1388
            dir.user_transport.get_segment_parameters())
1389
1389
        self.assertEquals("foo", dir._get_selected_branch())
1398
1398
        except (errors.NotLocalUrl, errors.UnsupportedOperation):
1399
1399
            raise TestSkipped("Can't initialize %r on transport %r"
1400
1400
                              % (self.bzrdir_format, t))
1401
 
        dir = bzrdir.BzrDir.open(t.base)
 
1401
        dir = controldir.ControlDir.open(t.base)
1402
1402
        self.assertEqual(u"", dir._get_selected_branch())
1403
1403
 
1404
1404
    def test_root_transport(self):
1473
1473
            raise TestNotApplicable("format does not support "
1474
1474
                "nesting repositories")
1475
1475
        child_repo = self.make_repository('childrepo')
1476
 
        opened_control = bzrdir.BzrDir.open(self.get_url('childrepo'))
 
1476
        opened_control = controldir.ControlDir.open(self.get_url('childrepo'))
1477
1477
        found_repo = opened_control.find_repository()
1478
1478
        self.assertEqual(child_repo.bzrdir.root_transport.base,
1479
1479
                         found_repo.bzrdir.root_transport.base)
1493
1493
        self.get_transport().mkdir('childrepo')
1494
1494
        child_control = self.bzrdir_format.initialize(url)
1495
1495
        child_repo = child_control.create_repository(shared=True)
1496
 
        opened_control = bzrdir.BzrDir.open(self.get_url('childrepo'))
 
1496
        opened_control = controldir.ControlDir.open(self.get_url('childrepo'))
1497
1497
        found_repo = opened_control.find_repository()
1498
1498
        self.assertEqual(child_repo.bzrdir.root_transport.base,
1499
1499
                         found_repo.bzrdir.root_transport.base)
1713
1713
        except errors.BzrError, e:
1714
1714
            if 'Cannot set config' in str(e):
1715
1715
                self.assertFalse(
1716
 
                    isinstance(my_dir, (bzrdir.BzrDirMeta1, RemoteBzrDir)),
 
1716
                    isinstance(my_dir, (_mod_bzrdir.BzrDirMeta1, RemoteBzrDir)),
1717
1717
                    "%r should support configs" % my_dir)
1718
1718
                raise TestNotApplicable(
1719
1719
                    'This BzrDir format does not support configs.')
1720
1720
            else:
1721
1721
                raise
1722
1722
        self.assertEqual('http://example.com', config.get_default_stack_on())
1723
 
        my_dir2 = bzrdir.BzrDir.open(self.get_url('.'))
 
1723
        my_dir2 = controldir.ControlDir.open(self.get_url('.'))
1724
1724
        config2 = my_dir2.get_config()
1725
1725
        self.assertEqual('http://example.com', config2.get_default_stack_on())
1726
1726
 
1748
1748
            return
1749
1749
        except errors.NoRepositoryPresent:
1750
1750
            pass
1751
 
        made_control = bzrdir.BzrDir.open(self.get_readonly_url('subdir'))
 
1751
        made_control = controldir.ControlDir.open(self.get_readonly_url('subdir'))
1752
1752
        self.assertRaises(errors.NoRepositoryPresent,
1753
1753
                          made_control.find_repository)
1754
1754