~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_graph.py

  • Committer: Robert J. Tanner
  • Date: 2009-06-10 03:56:49 UTC
  • mfrom: (4423 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4425.
  • Revision ID: tanner@real-time.com-20090610035649-7rfx4cls4550zc3c
Merge 1.15.1 back to trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
    )
23
23
from bzrlib.revision import NULL_REVISION
24
24
from bzrlib.tests import TestCaseWithMemoryTransport
 
25
from bzrlib.symbol_versioning import deprecated_in 
25
26
 
26
27
 
27
28
# Ancestry 1:
661
662
        self.assertEqual((set(['e']), set(['f', 'g'])),
662
663
                         graph.find_difference('e', 'f'))
663
664
 
 
665
 
664
666
    def test_stacked_parents_provider(self):
665
667
        parents1 = _mod_graph.DictParentsProvider({'rev2': ['rev3']})
666
668
        parents2 = _mod_graph.DictParentsProvider({'rev1': ['rev4']})
667
 
        stacked = _mod_graph._StackedParentsProvider([parents1, parents2])
 
669
        stacked = _mod_graph.StackedParentsProvider([parents1, parents2])
 
670
        self.assertEqual({'rev1':['rev4'], 'rev2':['rev3']},
 
671
                         stacked.get_parent_map(['rev1', 'rev2']))
 
672
        self.assertEqual({'rev2':['rev3'], 'rev1':['rev4']},
 
673
                         stacked.get_parent_map(['rev2', 'rev1']))
 
674
        self.assertEqual({'rev2':['rev3']},
 
675
                         stacked.get_parent_map(['rev2', 'rev2']))
 
676
        self.assertEqual({'rev1':['rev4']},
 
677
                         stacked.get_parent_map(['rev1', 'rev1']))
 
678
    
 
679
    def test_stacked_parents_provider_overlapping(self):
 
680
        # rev2 is availible in both providers.
 
681
        # 1
 
682
        # |
 
683
        # 2
 
684
        parents1 = _mod_graph.DictParentsProvider({'rev2': ['rev1']})
 
685
        parents2 = _mod_graph.DictParentsProvider({'rev2': ['rev1']})
 
686
        stacked = _mod_graph.StackedParentsProvider([parents1, parents2])
 
687
        self.assertEqual({'rev2': ['rev1']},
 
688
                         stacked.get_parent_map(['rev2']))
 
689
 
 
690
    def test__stacked_parents_provider_deprecated(self):
 
691
        parents1 = _mod_graph.DictParentsProvider({'rev2': ['rev3']})
 
692
        parents2 = _mod_graph.DictParentsProvider({'rev1': ['rev4']})
 
693
        stacked = self.applyDeprecated(deprecated_in((1, 16, 0)),
 
694
                    _mod_graph._StackedParentsProvider, [parents1, parents2])
668
695
        self.assertEqual({'rev1':['rev4'], 'rev2':['rev3']},
669
696
                         stacked.get_parent_map(['rev1', 'rev2']))
670
697
        self.assertEqual({'rev2':['rev3'], 'rev1':['rev4']},
1558
1585
        result = _mod_graph.PendingAncestryResult(['rev-2'], repo)
1559
1586
        self.assertEqual(set(['rev-1', 'rev-2']), set(result.get_keys()))
1560
1587
 
 
1588
    def test_get_keys_excludes_ghosts(self):
 
1589
        builder = self.make_branch_builder('b')
 
1590
        builder.start_series()
 
1591
        builder.build_snapshot('rev-1', None, [
 
1592
            ('add', ('', 'root-id', 'directory', ''))])
 
1593
        builder.build_snapshot('rev-2', ['rev-1', 'ghost'], [])
 
1594
        builder.finish_series()
 
1595
        repo = builder.get_branch().repository
 
1596
        repo.lock_read()
 
1597
        self.addCleanup(repo.unlock)
 
1598
        result = _mod_graph.PendingAncestryResult(['rev-2'], repo)
 
1599
        self.assertEqual(sorted(['rev-1', 'rev-2']), sorted(result.get_keys()))
 
1600
 
1561
1601
    def test_get_keys_excludes_null(self):
1562
1602
        # Make a 'graph' with an iter_ancestry that returns NULL_REVISION
1563
1603
        # somewhere other than the last element, which can happen in real