285
287
vf = self.get_file()
286
288
self.assertEqual(['base'], vf.get_parents('notbase'))
290
def test_fix_parents_with_ghosts(self):
291
# when fixing parents, ghosts that are listed should not be ghosts
296
vf.add_lines_with_ghosts('notbase', ['base', 'stillghost'], [])
297
except NotImplementedError:
299
vf.add_lines('base', [], [])
300
vf.fix_parents('notbase', ['base', 'stillghost'])
301
self.assertEqual(['base'], vf.get_parents('notbase'))
302
# open again, check it stuck.
304
self.assertEqual(['base'], vf.get_parents('notbase'))
305
# and check the ghosts
306
self.assertEqual(['base', 'stillghost'],
307
vf.get_parents_with_ghosts('notbase'))
309
def test_add_lines_with_ghosts(self):
310
# some versioned file formats allow lines to be added with parent
311
# information that is > than that in the format. Formats that do
312
# not support this need to raise NotImplementedError on the
313
# add_lines_with_ghosts api.
315
# add a revision with ghost parents
317
vf.add_lines_with_ghosts('notbase', ['base'], [])
318
except NotImplementedError:
319
# check the other ghost apis are also not implemented
320
self.assertRaises(NotImplementedError, vf.has_ghost, 'foo')
321
self.assertRaises(NotImplementedError, vf.get_ancestry_with_ghosts, ['foo'])
322
self.assertRaises(NotImplementedError, vf.get_parents_with_ghosts, 'foo')
323
self.assertRaises(NotImplementedError, vf.get_graph_with_ghosts)
325
# test key graph related apis: getncestry, _graph, get_parents
327
# - these are ghost unaware and must not be reflect ghosts
328
self.assertEqual(['notbase'], vf.get_ancestry('notbase'))
329
self.assertEqual([], vf.get_parents('notbase'))
330
self.assertEqual({'notbase':[]}, vf.get_graph())
331
self.assertFalse(vf.has_version('base'))
332
# we have _with_ghost apis to give us ghost information.
333
self.assertEqual(['base', 'notbase'], vf.get_ancestry_with_ghosts(['notbase']))
334
self.assertEqual(['base'], vf.get_parents_with_ghosts('notbase'))
335
self.assertEqual({'notbase':['base']}, vf.get_graph_with_ghosts())
336
self.assertTrue(vf.has_ghost('base'))
337
# if we add something that is a ghost of another, it should correct the
338
# results of the prior apis
339
vf.add_lines('base', [], [])
340
self.assertEqual(['base', 'notbase'], vf.get_ancestry(['notbase']))
341
self.assertEqual(['base'], vf.get_parents('notbase'))
342
self.assertEqual({'base':[],
346
self.assertTrue(vf.has_version('base'))
347
# we have _with_ghost apis to give us ghost information.
348
self.assertEqual(['base', 'notbase'], vf.get_ancestry_with_ghosts(['notbase']))
349
self.assertEqual(['base'], vf.get_parents_with_ghosts('notbase'))
350
self.assertEqual({'base':[],
353
vf.get_graph_with_ghosts())
354
self.assertFalse(vf.has_ghost('base'))
289
357
class TestWeave(TestCaseWithTransport, VersionedFileTestMixIn):