~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_repository.py

  • Committer: Jelmer Vernooij
  • Date: 2011-04-09 19:25:42 UTC
  • mto: (5777.5.1 inventoryworkingtree)
  • mto: This revision was merged to the branch mainline in revision 5781.
  • Revision ID: jelmer@samba.org-20110409192542-8bbedp36s7nj928e
Split InventoryTree out of Tree.

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
    revision as _mod_revision,
53
53
    upgrade,
54
54
    versionedfile,
55
 
    vf_repository,
56
55
    workingtree,
57
56
    )
58
57
from bzrlib.repofmt import (
136
135
        def check_format(format, url):
137
136
            dir = format._matchingbzrdir.initialize(url)
138
137
            format.initialize(dir)
139
 
            t = transport.get_transport_from_path(url)
 
138
            t = transport.get_transport(url)
140
139
            found_format = repository.RepositoryFormat.find_format(dir)
141
 
            self.assertIsInstance(found_format, format.__class__)
 
140
            self.failUnless(isinstance(found_format, format.__class__))
142
141
        check_format(repository.format_registry.get_default(), "bar")
143
142
 
144
143
    def test_find_format_no_repository(self):
379
378
        # classes do not barf inappropriately when a surprising repository type
380
379
        # is handed to them.
381
380
        dummy_a = DummyRepository()
382
 
        dummy_a._format = RepositoryFormat()
383
 
        dummy_a._format.supports_full_versioned_files = True
384
381
        dummy_b = DummyRepository()
385
 
        dummy_b._format = RepositoryFormat()
386
 
        dummy_b._format.supports_full_versioned_files = True
387
382
        self.assertGetsDefaultInterRepository(dummy_a, dummy_b)
388
383
 
389
384
    def assertGetsDefaultInterRepository(self, repo_a, repo_b):
393
388
        no actual sane default in the presence of incompatible data models.
394
389
        """
395
390
        inter_repo = repository.InterRepository.get(repo_a, repo_b)
396
 
        self.assertEqual(vf_repository.InterSameDataRepository,
 
391
        self.assertEqual(repository.InterSameDataRepository,
397
392
                         inter_repo.__class__)
398
393
        self.assertEqual(repo_a, inter_repo.source)
399
394
        self.assertEqual(repo_b, inter_repo.target)
413
408
        dummy_a._serializer = repo._serializer
414
409
        dummy_a._format.supports_tree_reference = repo._format.supports_tree_reference
415
410
        dummy_a._format.rich_root_data = repo._format.rich_root_data
416
 
        dummy_a._format.supports_full_versioned_files = repo._format.supports_full_versioned_files
417
411
        dummy_b._serializer = repo._serializer
418
412
        dummy_b._format.supports_tree_reference = repo._format.supports_tree_reference
419
413
        dummy_b._format.rich_root_data = repo._format.rich_root_data
420
 
        dummy_b._format.supports_full_versioned_files = repo._format.supports_full_versioned_files
421
414
        repository.InterRepository.register_optimiser(InterDummy)
422
415
        try:
423
416
            # we should get the default for something InterDummy returns False
673
666
        target = self.make_repository('target', format='rich-root-pack')
674
667
        stream = source._get_source(target._format)
675
668
        # We don't want the child GroupCHKStreamSource
676
 
        self.assertIs(type(stream), vf_repository.StreamSource)
 
669
        self.assertIs(type(stream), repository.StreamSource)
677
670
 
678
671
    def test_get_stream_for_missing_keys_includes_all_chk_refs(self):
679
672
        source_builder = self.make_branch_builder('source',
788
781
        source = self.make_repository('source', format='pack-0.92')
789
782
        target = self.make_repository('target', format='1.9')
790
783
        stream = source._get_source(target._format)
791
 
        self.assertIs(type(stream), vf_repository.StreamSource)
 
784
        self.assertIs(type(stream), repository.StreamSource)
792
785
 
793
786
    def test_stream_source_to_non_exact_rich_root(self):
794
787
        source = self.make_repository('source', format='1.9')
795
788
        target = self.make_repository('target', format='1.9-rich-root')
796
789
        stream = source._get_source(target._format)
797
 
        self.assertIs(type(stream), vf_repository.StreamSource)
 
790
        self.assertIs(type(stream), repository.StreamSource)
798
791
 
799
792
    def test_source_to_remote_non_exact_pack_19(self):
800
793
        trans = self.make_smart_server('target')
803
796
        target = self.make_repository('target', format='1.6')
804
797
        target = repository.Repository.open(trans.base)
805
798
        stream_source = source._get_source(target._format)
806
 
        self.assertIs(type(stream_source), vf_repository.StreamSource)
 
799
        self.assertIs(type(stream_source), repository.StreamSource)
807
800
 
808
801
    def test_stream_source_to_knit(self):
809
802
        source = self.make_repository('source', format='pack-0.92')
810
803
        target = self.make_repository('target', format='dirstate')
811
804
        stream = source._get_source(target._format)
812
 
        self.assertIs(type(stream), vf_repository.StreamSource)
 
805
        self.assertIs(type(stream), repository.StreamSource)
813
806
 
814
807
 
815
808
class TestDevelopment6FindParentIdsOfRevisions(TestCaseWithTransport):
1451
1444
        # Because of how they were built, they correspond to
1452
1445
        # ['D', 'C', 'B', 'A']
1453
1446
        packs = b.repository._pack_collection.packs
1454
 
        packer = knitpack_repo.KnitPacker(b.repository._pack_collection,
 
1447
        packer = pack_repo.Packer(b.repository._pack_collection,
1455
1448
                                  packs, 'testing',
1456
1449
                                  revision_ids=['B', 'C'])
1457
1450
        # Now, when we are copying the B & C revisions, their pack files should
1471
1464
        return repo._pack_collection
1472
1465
 
1473
1466
    def test_open_pack_will_optimise(self):
1474
 
        packer = knitpack_repo.OptimisingKnitPacker(self.get_pack_collection(),
 
1467
        packer = pack_repo.OptimisingPacker(self.get_pack_collection(),
1475
1468
                                            [], '.test')
1476
1469
        new_pack = packer.open_pack()
1477
1470
        self.addCleanup(new_pack.abort) # ensure cleanup
1602
1595
        self.addCleanup(target.unlock)
1603
1596
        source = source_tree.branch.repository._get_source(target._format)
1604
1597
        self.orig_pack = target.pack
1605
 
        self.overrideAttr(target, "pack", self.log_pack)
 
1598
        target.pack = self.log_pack
1606
1599
        search = target.search_missing_revision_ids(
1607
1600
            source_tree.branch.repository, revision_ids=[tip])
1608
1601
        stream = source.get_stream(search)
1626
1619
        self.addCleanup(target.unlock)
1627
1620
        source = source_tree.branch.repository
1628
1621
        self.orig_pack = target.pack
1629
 
        self.overrideAttr(target, "pack", self.log_pack)
 
1622
        target.pack = self.log_pack
1630
1623
        target.fetch(source)
1631
1624
        if expect_pack_called:
1632
1625
            self.assertLength(1, self.calls)
1660
1653
    def test_IDS_format_same_no(self):
1661
1654
        # When the formats are the same, pack is not called.
1662
1655
        self.run_fetch('2a', '2a', False)
1663
 
 
1664
 
 
1665
 
class Test_LazyListJoin(tests.TestCase):
1666
 
 
1667
 
    def test__repr__(self):
1668
 
        lazy = repository._LazyListJoin(['a'], ['b'])
1669
 
        self.assertEqual("bzrlib.repository._LazyListJoin((['a'], ['b']))",
1670
 
                         repr(lazy))