~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/bzrdir_implementations/test_bzrdir.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-03-29 04:35:40 UTC
  • mfrom: (2381.1.4 hpss-test-correctness)
  • Revision ID: pqm@pqm.ubuntu.com-20070329043540-952aff23533c1c26
(robertc) Various test suite changes and cleanups in preparation for the next hpss branch. (Robert Collins, Andrew Bennetts)

Show diffs side-by-side

added added

removed removed

Lines of Context:
155
155
        dir = self.make_bzrdir('dir1')
156
156
        dir.create_repository()
157
157
        dir.create_branch()
158
 
        wt = dir.create_workingtree(revision_id=bzrlib.revision.NULL_REVISION)
 
158
        try:
 
159
            wt = dir.create_workingtree(revision_id=bzrlib.revision.NULL_REVISION)
 
160
        except errors.NotLocalUrl:
 
161
            raise TestSkipped("cannot make working tree with transport %r"
 
162
                              % dir.transport)
159
163
        self.assertEqual([], wt.get_parent_ids())
160
164
 
161
165
    def test_destroy_workingtree(self):
312
316
 
313
317
    def test_clone_bzrdir_branch_and_repo(self):
314
318
        tree = self.make_branch_and_tree('commit_tree')
315
 
        self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
 
319
        self.build_tree(['foo'], transport=tree.bzrdir.root_transport)
316
320
        tree.add('foo')
317
321
        tree.commit('revision 1')
318
322
        source = self.make_branch('source')
319
 
        tree.bzrdir.open_repository().copy_content_into(source.repository)
320
 
        tree.bzrdir.open_branch().copy_content_into(source)
 
323
        tree.branch.repository.copy_content_into(source.repository)
 
324
        tree.branch.copy_content_into(source)
321
325
        dir = source.bzrdir
322
326
        target = dir.clone(self.get_url('target'))
323
327
        self.assertNotEqual(dir.transport.base, target.transport.base)
333
337
    def test_clone_bzrdir_branch_and_repo_into_shared_repo(self):
334
338
        # by default cloning into a shared repo uses the shared repo.
335
339
        tree = self.make_branch_and_tree('commit_tree')
336
 
        self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
 
340
        self.build_tree(['foo'], transport=tree.bzrdir.root_transport)
337
341
        tree.add('foo')
338
342
        tree.commit('revision 1')
339
343
        source = self.make_branch('source')
340
 
        tree.bzrdir.open_repository().copy_content_into(source.repository)
341
 
        tree.bzrdir.open_branch().copy_content_into(source)
 
344
        tree.branch.repository.copy_content_into(source.repository)
 
345
        tree.branch.copy_content_into(source)
342
346
        try:
343
347
            self.make_repository('target', shared=True)
344
348
        except errors.IncompatibleFormat:
353
357
    def test_clone_bzrdir_branch_and_repo_into_shared_repo_force_new_repo(self):
354
358
        # by default cloning into a shared repo uses the shared repo.
355
359
        tree = self.make_branch_and_tree('commit_tree')
356
 
        self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
 
360
        self.build_tree(['foo'], transport=tree.bzrdir.root_transport)
357
361
        tree.add('foo')
358
362
        tree.commit('revision 1')
359
363
        source = self.make_branch('source')
360
 
        tree.bzrdir.open_repository().copy_content_into(source.repository)
361
 
        tree.bzrdir.open_branch().copy_content_into(source)
 
364
        tree.branch.repository.copy_content_into(source.repository)
 
365
        tree.branch.copy_content_into(source)
362
366
        try:
363
367
            self.make_repository('target', shared=True)
364
368
        except errors.IncompatibleFormat:
398
402
        tree.commit('revision 1', rev_id='1')
399
403
        tree.commit('revision 2', rev_id='2', allow_pointless=True)
400
404
        source = self.make_branch('source')
401
 
        tree.bzrdir.open_repository().copy_content_into(source.repository)
402
 
        tree.bzrdir.open_branch().copy_content_into(source)
 
405
        tree.branch.repository.copy_content_into(source.repository)
 
406
        tree.branch.copy_content_into(source)
403
407
        dir = source.bzrdir
404
408
        target = dir.clone(self.get_url('target'), revision_id='1')
405
409
        self.assertEqual('1', target.open_branch().last_revision())
874
878
            return
875
879
        self.assertRaises(errors.NoRepositoryPresent, dir.open_repository)
876
880
        tree = self.createWorkingTreeOrSkip(dir)
877
 
        tree.bzrdir.root_transport.mkdir('subdir')
 
881
        self.build_tree(['source/subdir/'])
878
882
        tree.add('subdir')
879
883
        target = self.sproutOrSkip(dir, self.get_url('target'))
880
884
        self.assertNotEqual(dir.transport.base, target.transport.base)
900
904
            return
901
905
        self.assertRaises(errors.NoRepositoryPresent, dir.open_repository)
902
906
        tree = self.createWorkingTreeOrSkip(dir)
903
 
        self.build_tree(['foo'], transport=dir.root_transport)
 
907
        self.build_tree(['source/foo'])
904
908
        tree.add('foo')
905
909
        tree.commit('revision 1', rev_id='1')
906
910
        tree.commit('revision 2', rev_id='2', allow_pointless=True)
923
927
        # This smoke test just checks the revision-id is right. Tree specific
924
928
        # tests will check corner cases.
925
929
        tree = self.make_branch_and_tree('source')
926
 
        self.build_tree(['foo'], transport=tree.bzrdir.root_transport)
 
930
        self.build_tree(['source/foo'])
927
931
        tree.add('foo')
928
932
        tree.commit('revision 1', rev_id='1')
929
933
        tree.commit('revision 2', rev_id='2', allow_pointless=True)
934
938
    def test_sprout_bzrdir_incomplete_source_with_basis(self):
935
939
        # ensure that basis really does grab from the basis by having incomplete source
936
940
        tree = self.make_branch_and_tree('commit_tree')
937
 
        self.build_tree(['foo'], transport=tree.bzrdir.root_transport)
 
941
        self.build_tree(['commit_tree/foo'])
938
942
        tree.add('foo')
939
943
        tree.commit('revision 1', rev_id='1')
940
944
        source = self.make_branch_and_tree('source')
1018
1022
        t = get_transport(self.get_url())
1019
1023
        made_control = self.bzrdir_format.initialize(t.base)
1020
1024
        made_repo = made_control.create_repository()
1021
 
        self.failUnless(isinstance(made_repo, repository.Repository))
 
1025
        # Check that we have a repository object.
 
1026
        made_repo.has_revision('foo')
1022
1027
        self.assertEqual(made_control, made_repo.bzrdir)
1023
1028
 
1024
1029
    def test_create_repository_shared(self):
1103
1108
            # because the default open will not open them and
1104
1109
            # they may not be initializable.
1105
1110
            return
1106
 
        # this has to be tested with local access as we still support creating 
 
1111
        # this has to be tested with local access as we still support creating
1107
1112
        # format 6 bzrdirs
1108
 
        t = get_transport('.')
1109
 
        made_control = self.bzrdir_format.initialize(t.base)
1110
 
        made_repo = made_control.create_repository()
1111
 
        made_branch = made_control.create_branch()
1112
 
        made_tree = made_control.create_workingtree()
 
1113
        t = self.get_transport()
 
1114
        try:
 
1115
            made_control = self.bzrdir_format.initialize(t.base)
 
1116
            made_repo = made_control.create_repository()
 
1117
            made_branch = made_control.create_branch()
 
1118
            made_tree = made_control.create_workingtree()
 
1119
        except errors.NotLocalUrl:
 
1120
            raise TestSkipped("Can't initialize %r on transport %r"
 
1121
                              % (self.bzrdir_format, t))
1113
1122
        opened_tree = made_control.open_workingtree()
1114
1123
        self.assertEqual(made_control, opened_tree.bzrdir)
1115
1124
        self.failUnless(isinstance(opened_tree, made_tree.__class__))
1456
1465
            # they may not be initializable.
1457
1466
            return
1458
1467
        # supported formats must be able to init and open
1459
 
        url = self.get_url('subdir')
1460
 
        get_transport(self.get_url()).mkdir('subdir')
1461
 
        made_control = self.bzrdir_format.initialize(url)
 
1468
        # - do the vfs initialisation over the basic vfs transport
 
1469
        # XXX: TODO this should become a 'bzrdirlocation' api call.
 
1470
        url = self.get_vfs_only_url('subdir')
 
1471
        get_transport(self.get_vfs_only_url()).mkdir('subdir')
 
1472
        made_control = self.bzrdir_format.initialize(self.get_url('subdir'))
1462
1473
        try:
1463
1474
            repo = made_control.open_repository()
1464
1475
            # if there is a repository, then the format cannot ever hit this 
1466
1477
            return
1467
1478
        except errors.NoRepositoryPresent:
1468
1479
            pass
1469
 
        opened_control = bzrdir.BzrDir.open(self.get_readonly_url('subdir'))
 
1480
        made_control = bzrdir.BzrDir.open(self.get_readonly_url('subdir'))
1470
1481
        self.assertRaises(errors.NoRepositoryPresent,
1471
 
                          opened_control.find_repository)
 
1482
                          made_control.find_repository)
1472
1483