453
453
graph.heads(['rev2a', 'rev3b']))
454
454
self.assertEqual(set(['rev2c', 'rev3a']),
455
455
graph.heads(['rev2c', 'rev3a']))
458
def _run_heads_break_deeper(self, graph_dict, search):
459
"""Run heads on a graph-as-a-dict.
461
If the search asks for the parents of 'deeper' the test will fail.
465
def get_parents(keys):
469
import pdb;pdb.set_trace()
470
self.fail('key deeper was accessed')
471
result.append(graph_dict[key])
474
an_obj.get_parents = get_parents
475
graph = _mod_graph.Graph(an_obj)
476
return graph.heads(search)
478
def test_heads_limits_search(self):
479
# test that a heads query does not search all of history
485
self.assertEqual(set(['left', 'right']),
486
self._run_heads_break_deeper(graph_dict, ['left', 'right']))
488
def test_heads_limits_search_assymetric(self):
489
# test that a heads query does not search all of history
492
'midleft':['common'],
494
'common':['aftercommon'],
495
'aftercommon':['deeper'],
497
self.assertEqual(set(['left', 'right']),
498
self._run_heads_break_deeper(graph_dict, ['left', 'right']))
500
def test_heads_limits_search_common_search_must_continue(self):
501
# test that common nodes are still queried, preventing
502
# all-the-way-to-origin behaviour in the following graph:
504
'h1':['shortcut', 'common1'],
506
'shortcut':['common2'],
507
'common1':['common2'],
508
'common2':['deeper'],
510
self.assertEqual(set(['h1', 'h2']),
511
self._run_heads_break_deeper(graph_dict, ['h1', 'h2']))