89
89
class MergeSortTests(TestCase):
91
def assertSortAndIterate(self, graph, branch_tip, result_list):
91
def assertSortAndIterate(self, graph, branch_tip, result_list,
92
mainline_revisions=None):
92
93
"""Check that merge based sorting and iter_topo_order on graph works."""
93
self.assertEquals(result_list, merge_sort(graph, branch_tip))
94
self.assertEquals(result_list,
95
merge_sort(graph, branch_tip, mainline_revisions=mainline_revisions))
94
96
self.assertEqual(result_list,
95
list(MergeSorter(graph, branch_tip).iter_topo_order()))
100
mainline_revisions=mainline_revisions).iter_topo_order()))
97
102
def test_merge_sort_empty(self):
98
103
# sorting of an emptygraph does not error
219
224
(7, 'H', 0, True),
228
def test_mainline_revs_partial(self):
229
# when a mainline_revisions list is passed this must
230
# override the graphs idea of mainline, and must also
231
# truncate the output to the specified range, if needed.
232
# so we test both at once: a mainline_revisions list that
233
# disagrees with the graph about which revs are 'mainline'
234
# and also truncates the output.
241
# with a mainline of NONE,E,A (the inferred one) this will show the merge
243
# with a overriden mainline of NONE,E,D,B,A it should show:
249
# and thus when truncated to D,B,A it should show
253
# because C is brought in by B in this view and D
254
# is the terminating revision id
255
self.assertSortAndIterate(
267
mainline_revisions=['D', 'B', 'A']
270
def test_mainline_revs_with_none(self):
271
# a simple test to ensure that a mainline_revs
272
# list which goes all the way to None works
273
self.assertSortAndIterate(
279
mainline_revisions=[None, 'A']