661
662
self.assertEqual((set(['e']), set(['f', 'g'])),
662
663
graph.find_difference('e', 'f'))
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']))
679
def test_stacked_parents_provider_overlapping(self):
680
# rev2 is availible in both providers.
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']))
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()))
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
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()))
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