699
698
self.assertEqual({'rev2': ['rev1']},
700
699
stacked.get_parent_map(['rev2']))
702
def test__stacked_parents_provider_deprecated(self):
703
parents1 = _mod_graph.DictParentsProvider({'rev2': ['rev3']})
704
parents2 = _mod_graph.DictParentsProvider({'rev1': ['rev4']})
705
stacked = self.applyDeprecated(deprecated_in((1, 16, 0)),
706
_mod_graph._StackedParentsProvider, [parents1, parents2])
707
self.assertEqual({'rev1':['rev4'], 'rev2':['rev3']},
708
stacked.get_parent_map(['rev1', 'rev2']))
709
self.assertEqual({'rev2':['rev3'], 'rev1':['rev4']},
710
stacked.get_parent_map(['rev2', 'rev1']))
711
self.assertEqual({'rev2':['rev3']},
712
stacked.get_parent_map(['rev2', 'rev2']))
713
self.assertEqual({'rev1':['rev4']},
714
stacked.get_parent_map(['rev1', 'rev1']))
716
701
def test_iter_topo_order(self):
717
702
graph = self.make_graph(ancestry_1)
718
703
args = ['rev2a', 'rev3', 'rev1']
1661
1646
self.assertEqual(['B', 'D'],
1662
1647
sorted(graph_thunk.heads(['D', 'B', 'A'])))
1649
def test_merge_sort(self):
1650
d = {('C',):[('A',)], ('B',): [('A',)], ('A',): []}
1651
g = _mod_graph.KnownGraph(d)
1652
graph_thunk = _mod_graph.GraphThunkIdsToKeys(g)
1653
graph_thunk.add_node("D", ["A", "C"])
1654
self.assertEqual([('C', 0, (2,), False), ('A', 0, (1,), True)],
1655
[(n.key, n.merge_depth, n.revno, n.end_of_merge)
1656
for n in graph_thunk.merge_sort('C')])
1665
1659
class TestPendingAncestryResultGetKeys(TestCaseWithMemoryTransport):
1666
1660
"""Tests for bzrlib.graph.PendingAncestryResult."""