/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

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

merge trailing whitespace removal

Show diffs side-by-side

added added

removed removed

Lines of Context:
75
75
        """Assert that the content of source and target are identical.
76
76
 
77
77
        paths in ignore list will be completely ignored.
78
 
        
 
78
 
79
79
        We ignore paths that represent data which is allowed to change during
80
80
        a clone or sprout: for instance, inventory.knit contains gzip fragements
81
 
        which have timestamps in them, and as we have read the inventory from 
 
81
        which have timestamps in them, and as we have read the inventory from
82
82
        the source knit, the already-read data is recompressed rather than
83
83
        reading it again, which leads to changed timestamps. This is ok though,
84
84
        because the inventory.kndx file is not ignored, and the integrity of
169
169
 
170
170
    def skipIfNoWorkingTree(self, a_bzrdir):
171
171
        """Raises TestSkipped if a_bzrdir doesn't have a working tree.
172
 
        
 
172
 
173
173
        If the bzrdir does have a workingtree, this is a no-op.
174
174
        """
175
175
        try:
180
180
 
181
181
    def createWorkingTreeOrSkip(self, a_bzrdir):
182
182
        """Create a working tree on a_bzrdir, or raise TestSkipped.
183
 
        
 
183
 
184
184
        A simple wrapper for create_workingtree that translates NotLocalUrl into
185
185
        TestSkipped.  Returns the newly created working tree.
186
186
        """
193
193
    def sproutOrSkip(self, from_bzrdir, to_url, revision_id=None,
194
194
                     force_new_repo=False, accelerator_tree=None):
195
195
        """Sprout from_bzrdir into to_url, or raise TestSkipped.
196
 
        
 
196
 
197
197
        A simple wrapper for from_bzrdir.sprout that translates NotLocalUrl into
198
198
        TestSkipped.  Returns the newly sprouted bzrdir.
199
199
        """
284
284
        self.assertNotEqual(dir.transport.base, target.transport.base)
285
285
        self.assertDirectoriesEqual(dir.root_transport, target.root_transport,
286
286
                                    ['./.bzr/merge-hashes'])
287
 
    
 
287
 
288
288
    def test_clone_bzrdir_empty_force_new_ignored(self):
289
289
        # the force_new_repo parameter should have no effect on an empty
290
290
        # bzrdir's clone logic
293
293
        self.assertNotEqual(dir.transport.base, target.transport.base)
294
294
        self.assertDirectoriesEqual(dir.root_transport, target.root_transport,
295
295
                                    ['./.bzr/merge-hashes'])
296
 
    
 
296
 
297
297
    def test_clone_bzrdir_repository(self):
298
298
        tree = self.make_branch_and_tree('commit_tree')
299
299
        self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
387
387
        self.assertTrue(branch.repository.has_revision('1'))
388
388
        self.assertFalse(branch.repository.make_working_trees())
389
389
        self.assertTrue(branch.repository.is_shared())
390
 
        
 
390
 
391
391
    def test_clone_bzrdir_repository_under_shared_force_new_repo(self):
392
392
        tree = self.make_branch_and_tree('commit_tree')
393
393
        self.build_tree(['commit_tree/foo'])
412
412
        # test for revision limiting, [smoke test, not corner case checks].
413
413
        # make a repository with some revisions,
414
414
        # and clone it with a revision limit.
415
 
        # 
 
415
        #
416
416
        tree = self.make_branch_and_tree('commit_tree')
417
417
        self.build_tree(['commit_tree/foo'])
418
418
        tree.add('foo')
508
508
        # test for revision limiting, [smoke test, not corner case checks].
509
509
        # make a branch with some revisions,
510
510
        # and clone it with a revision limit.
511
 
        # 
 
511
        #
512
512
        tree = self.make_branch_and_tree('commit_tree')
513
513
        self.build_tree(['commit_tree/foo'])
514
514
        tree.add('foo')
520
520
        dir = source.bzrdir
521
521
        target = dir.clone(self.get_url('target'), revision_id='1')
522
522
        self.assertEqual('1', target.open_branch().last_revision())
523
 
        
 
523
 
524
524
    def test_clone_bzrdir_tree_branch_repo(self):
525
525
        tree = self.make_branch_and_tree('source')
526
526
        self.build_tree(['source/foo'])
590
590
            target.open_repository())
591
591
 
592
592
    def test_clone_bzrdir_tree_branch_reference(self):
593
 
        # a tree with a branch reference (aka a checkout) 
 
593
        # a tree with a branch reference (aka a checkout)
594
594
        # should stay a checkout on clone.
595
595
        referenced_branch = self.make_branch('referencced')
596
596
        dir = self.make_bzrdir('source')
720
720
        target.open_repository()
721
721
        target.open_branch()
722
722
        target.open_workingtree()
723
 
    
 
723
 
724
724
    def test_sprout_bzrdir_repository(self):
725
725
        tree = self.make_branch_and_tree('commit_tree')
726
726
        self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
751
751
            # If we happen to have a tree, we'll guarantee everything
752
752
            # except for the tree root is the same.
753
753
            inventory_f = file(dir.transport.base+'inventory', 'rb')
754
 
            self.assertContainsRe(inventory_f.read(), 
 
754
            self.assertContainsRe(inventory_f.read(),
755
755
                                  '<inventory file_id="TREE_ROOT[^"]*"'
756
756
                                  ' format="5">\n</inventory>\n')
757
757
            inventory_f.close()
850
850
        # test for revision limiting, [smoke test, not corner case checks].
851
851
        # make a repository with some revisions,
852
852
        # and sprout it with a revision limit.
853
 
        # 
 
853
        #
854
854
        tree = self.make_branch_and_tree('commit_tree')
855
855
        self.build_tree(['commit_tree/foo'])
856
856
        tree.add('foo')
943
943
        self.assertNotEqual(dir.transport.base, target.transport.base)
944
944
        # we want target to have a branch that is in-place.
945
945
        self.assertEqual(target, target.open_branch().bzrdir)
946
 
        # and as we dont support repositories being detached yet, a repo in 
 
946
        # and as we dont support repositories being detached yet, a repo in
947
947
        # place
948
948
        target.open_repository()
949
949
 
968
968
        # we want target to have a branch that is in-place.
969
969
        self.assertEqual(target, target.open_branch().bzrdir)
970
970
        # and we want no repository as the target is shared
971
 
        self.assertRaises(errors.NoRepositoryPresent, 
 
971
        self.assertRaises(errors.NoRepositoryPresent,
972
972
                          target.open_repository)
973
973
        # and we want revision '1' in the shared repo
974
974
        self.assertTrue(shared_repo.has_revision('1'))
1003
1003
        # test for revision limiting, [smoke test, not corner case checks].
1004
1004
        # make a repository with some revisions,
1005
1005
        # and sprout it with a revision limit.
1006
 
        # 
 
1006
        #
1007
1007
        tree = self.make_branch_and_tree('commit_tree')
1008
1008
        self.build_tree(['commit_tree/foo'])
1009
1009
        tree.add('foo')
1015
1015
        dir = source.bzrdir
1016
1016
        target = self.sproutOrSkip(dir, self.get_url('target'), revision_id='1')
1017
1017
        self.assertEqual('1', target.open_branch().last_revision())
1018
 
        
 
1018
 
1019
1019
    def test_sprout_bzrdir_tree_branch_repo(self):
1020
1020
        tree = self.make_branch_and_tree('source')
1021
1021
        self.build_tree(['foo'], transport=tree.bzrdir.transport.clone('..'))
1058
1058
        self.assertNotEqual(dir.transport.base, target.transport.base)
1059
1059
        # we want target to have a branch that is in-place.
1060
1060
        self.assertEqual(target, target.open_branch().bzrdir)
1061
 
        # and as we dont support repositories being detached yet, a repo in 
 
1061
        # and as we dont support repositories being detached yet, a repo in
1062
1062
        # place
1063
1063
        target.open_repository()
1064
1064
        result_tree = target.open_workingtree()
1087
1087
        self.assertNotEqual(dir.transport.base, target.transport.base)
1088
1088
        # we want target to have a branch that is in-place.
1089
1089
        self.assertEqual(target, target.open_branch().bzrdir)
1090
 
        # and as we dont support repositories being detached yet, a repo in 
 
1090
        # and as we dont support repositories being detached yet, a repo in
1091
1091
        # place
1092
1092
        target.open_repository()
1093
1093
        # we trust that the working tree sprouting works via the other tests.
1161
1161
        made_branch = made_control.create_branch()
1162
1162
        self.failUnless(isinstance(made_branch, bzrlib.branch.Branch))
1163
1163
        self.assertEqual(made_control, made_branch.bzrdir)
1164
 
        
 
1164
 
1165
1165
    def test_open_branch(self):
1166
1166
        if not self.bzrdir_format.is_supported():
1167
1167
            # unsupported formats are not loopback testable
1192
1192
        self.assertEqual(made_control, made_repo.bzrdir)
1193
1193
 
1194
1194
    def test_create_repository_shared(self):
1195
 
        # a bzrdir can create a shared repository or 
 
1195
        # a bzrdir can create a shared repository or
1196
1196
        # fail appropriately
1197
1197
        if not self.bzrdir_format.is_supported():
1198
1198
            # unsupported formats are not loopback testable
1210
1210
        self.assertTrue(made_repo.is_shared())
1211
1211
 
1212
1212
    def test_create_repository_nonshared(self):
1213
 
        # a bzrdir can create a non-shared repository 
 
1213
        # a bzrdir can create a non-shared repository
1214
1214
        if not self.bzrdir_format.is_supported():
1215
1215
            # unsupported formats are not loopback testable
1216
1216
            # because the default open will not open them and
1220
1220
        made_control = self.bzrdir_format.initialize(t.base)
1221
1221
        made_repo = made_control.create_repository(shared=False)
1222
1222
        self.assertFalse(made_repo.is_shared())
1223
 
        
 
1223
 
1224
1224
    def test_open_repository(self):
1225
1225
        if not self.bzrdir_format.is_supported():
1226
1226
            # unsupported formats are not loopback testable
1249
1249
        made_tree = self.createWorkingTreeOrSkip(made_control)
1250
1250
        self.failUnless(isinstance(made_tree, workingtree.WorkingTree))
1251
1251
        self.assertEqual(made_control, made_tree.bzrdir)
1252
 
        
 
1252
 
1253
1253
    def test_create_workingtree_revision(self):
1254
1254
        # a bzrdir can construct a working tree for itself @ a specific revision.
1255
1255
        t = self.get_transport()
1266
1266
        except errors.NotLocalUrl:
1267
1267
            raise TestSkipped("Can't make working tree on transport %r" % t)
1268
1268
        self.assertEqual(['a'], made_tree.get_parent_ids())
1269
 
        
 
1269
 
1270
1270
    def test_open_workingtree(self):
1271
1271
        if not self.bzrdir_format.is_supported():
1272
1272
            # unsupported formats are not loopback testable
1374
1374
            self.get_url('intermediate/child'))
1375
1375
        try:
1376
1376
            child_repo = innermost_control.open_repository()
1377
 
            # if there is a repository, then the format cannot ever hit this 
 
1377
            # if there is a repository, then the format cannot ever hit this
1378
1378
            # code path.
1379
1379
            return
1380
1380
        except errors.NoRepositoryPresent:
1395
1395
        made_control = self.bzrdir_format.initialize(url)
1396
1396
        try:
1397
1397
            child_repo = made_control.open_repository()
1398
 
            # if there is a repository, then the format cannot ever hit this 
 
1398
            # if there is a repository, then the format cannot ever hit this
1399
1399
            # code path.
1400
1400
            return
1401
1401
        except errors.NoRepositoryPresent:
1403
1403
        found_repo = made_control.find_repository()
1404
1404
        self.assertEqual(repo.bzrdir.root_transport.base,
1405
1405
                         found_repo.bzrdir.root_transport.base)
1406
 
        
 
1406
 
1407
1407
    def test_find_repository_standalone_with_containing_shared_repository(self):
1408
1408
        # find repo inside a standalone repo inside a shared repo finds the standalone repo
1409
1409
        try:
1436
1436
                            containing_repo.bzrdir.root_transport.base)
1437
1437
 
1438
1438
    def test_find_repository_with_nested_dirs_works(self):
1439
 
        # find repo inside a bzrdir inside a bzrdir inside a shared repo 
 
1439
        # find repo inside a bzrdir inside a bzrdir inside a shared repo
1440
1440
        # finds the outer shared repo.
1441
1441
        try:
1442
1442
            repo = self.make_repository('.', shared=True)
1449
1449
        made_control = self.bzrdir_format.initialize(url)
1450
1450
        try:
1451
1451
            child_repo = made_control.open_repository()
1452
 
            # if there is a repository, then the format cannot ever hit this 
 
1452
            # if there is a repository, then the format cannot ever hit this
1453
1453
            # code path.
1454
1454
            return
1455
1455
        except errors.NoRepositoryPresent:
1458
1458
            self.get_url('intermediate/child'))
1459
1459
        try:
1460
1460
            child_repo = innermost_control.open_repository()
1461
 
            # if there is a repository, then the format cannot ever hit this 
 
1461
            # if there is a repository, then the format cannot ever hit this
1462
1462
            # code path.
1463
1463
            return
1464
1464
        except errors.NoRepositoryPresent:
1466
1466
        found_repo = innermost_control.find_repository()
1467
1467
        self.assertEqual(repo.bzrdir.root_transport.base,
1468
1468
                         found_repo.bzrdir.root_transport.base)
1469
 
        
 
1469
 
1470
1470
    def test_can_and_needs_format_conversion(self):
1471
1471
        # check that we can ask an instance if its upgradable
1472
1472
        dir = self.make_bzrdir('.')
1473
1473
        if dir.can_convert_format():
1474
 
            # if its default updatable there must be an updater 
 
1474
            # if its default updatable there must be an updater
1475
1475
            # (we force the latest known format as downgrades may not be
1476
1476
            # available
1477
1477
            self.assertTrue(isinstance(dir._format.get_converter(
1488
1488
        new_path = urlutils.local_path_from_url(new_url)
1489
1489
        self.failUnlessExists(old_path)
1490
1490
        self.failUnlessExists(new_path)
1491
 
        for (((dir_relpath1, _), entries1), 
 
1491
        for (((dir_relpath1, _), entries1),
1492
1492
             ((dir_relpath2, _), entries2)) in izip(
1493
 
                osutils.walkdirs(old_path), 
 
1493
                osutils.walkdirs(old_path),
1494
1494
                osutils.walkdirs(new_path)):
1495
1495
            self.assertEquals(dir_relpath1, dir_relpath2)
1496
1496
            for f1, f2 in zip(entries1, entries2):
1507
1507
        dir.create_branch()
1508
1508
        self.createWorkingTreeOrSkip(dir)
1509
1509
        if dir.can_convert_format():
1510
 
            # if its default updatable there must be an updater 
 
1510
            # if its default updatable there must be an updater
1511
1511
            # (we force the latest known format as downgrades may not be
1512
1512
            # available
1513
1513
            pb = ui.ui_factory.nested_progress_bar()
1543
1543
            transport=transport)
1544
1544
        self.failUnless(transport.has('.bzr'))
1545
1545
        self.assertRaises((errors.FileExists, errors.DirectoryNotEmpty),
1546
 
            bd.retire_bzrdir, limit=0) 
 
1546
            bd.retire_bzrdir, limit=0)
1547
1547
 
1548
1548
 
1549
1549
class TestBreakLock(TestCaseWithBzrDir):
1638
1638
        self.assertRaises(errors.LockBroken, master.unlock)
1639
1639
 
1640
1640
    def test_break_lock_tree(self):
1641
 
        # break lock with a tree should unlock the tree but not try the 
1642
 
        # branch explicitly. However this is very hard to test for as we 
1643
 
        # dont have a tree reference class, nor is one needed; 
 
1641
        # break lock with a tree should unlock the tree but not try the
 
1642
        # branch explicitly. However this is very hard to test for as we
 
1643
        # dont have a tree reference class, nor is one needed;
1644
1644
        # the worst case if this code unlocks twice is an extra question
1645
1645
        # being asked.
1646
1646
        tree = self.make_branch_and_tree('.')
1684
1684
class ChrootedBzrDirTests(ChrootedTestCase):
1685
1685
 
1686
1686
    def test_find_repository_no_repository(self):
1687
 
        # loopback test to check the current format fails to find a 
 
1687
        # loopback test to check the current format fails to find a
1688
1688
        # share repository correctly.
1689
1689
        if not self.bzrdir_format.is_supported():
1690
1690
            # unsupported formats are not loopback testable
1699
1699
        made_control = self.bzrdir_format.initialize(self.get_url('subdir'))
1700
1700
        try:
1701
1701
            repo = made_control.open_repository()
1702
 
            # if there is a repository, then the format cannot ever hit this 
 
1702
            # if there is a repository, then the format cannot ever hit this
1703
1703
            # code path.
1704
1704
            return
1705
1705
        except errors.NoRepositoryPresent: