1228
1228
['h', 'i', 'j', 'y'], 'j', ['z'])
1231
class TestGraphFindRevno(tests.TestCase):
1232
"""Test an api that should be able to compute a revno"""
1234
def make_graph(self, ancestors):
1235
return _mod_graph.Graph(_mod_graph.DictParentsProvider(ancestors))
1237
def assertFindRevno(self, revno, graph, target_id, known_ids):
1238
"""Assert the output of Graph.find_revno()"""
1239
actual = graph.find_revno(target_id, known_ids)
1240
self.assertEqual(revno, actual)
1242
def test_nothing_known(self):
1243
graph = self.make_graph(ancestry_1)
1244
self.assertFindRevno(1, graph, 'rev1', [])
1245
self.assertFindRevno(2, graph, 'rev2a', [])
1246
self.assertFindRevno(2, graph, 'rev2b', [])
1247
self.assertFindRevno(3, graph, 'rev3', [])
1248
self.assertFindRevno(4, graph, 'rev4', [])
1250
def test_rev_is_ghost(self):
1251
graph = self.make_graph(ancestry_1)
1252
e = self.assertRaises(errors.GhostRevisionsHaveNoRevno,
1253
graph.find_revno, 'rev_missing', [])
1254
self.assertEqual('rev_missing', e.revision_id)
1255
self.assertEqual('rev_missing', e.ghost_revision_id)
1257
def test_ancestor_is_ghost(self):
1258
graph = self.make_graph({'rev':['parent']})
1259
e = self.assertRaises(errors.GhostRevisionsHaveNoRevno,
1260
graph.find_revno, 'rev', [])
1261
self.assertEqual('rev', e.revision_id)
1262
self.assertEqual('parent', e.ghost_revision_id)
1231
1265
class TestCachingParentsProvider(tests.TestCase):
1233
1267
def setUp(self):