351
351
f.transaction_finished()
352
352
self.assertRaises(errors.OutSideTransaction, f.add_lines, '', [], [])
353
353
self.assertRaises(errors.OutSideTransaction, f.add_lines_with_ghosts, '', [], [])
354
self.assertRaises(errors.OutSideTransaction, f.fix_parents, '', [])
355
354
self.assertRaises(errors.OutSideTransaction, f.join, '')
356
355
self.assertRaises(errors.OutSideTransaction, f.clone_text, 'base', 'bar', ['foo'])
598
597
self.assertTrue(lines['child\n'] > 0)
599
598
self.assertTrue(lines['otherchild\n'] > 0)
601
def test_fix_parents(self):
602
# some versioned files allow incorrect parents to be corrected after
603
# insertion - this may not fix ancestry..
604
# if they do not supported, they just do not implement it.
605
# we test this as an interface test to ensure that those that *do*
606
# implementent it get it right.
608
vf.add_lines('notbase', [], [])
609
vf.add_lines('base', [], [])
611
vf.fix_parents('notbase', ['base'])
612
except NotImplementedError:
614
self.assertEqual(['base'], vf.get_parents('notbase'))
615
# open again, check it stuck.
617
self.assertEqual(['base'], vf.get_parents('notbase'))
619
def test_fix_parents_with_ghosts(self):
620
# when fixing parents, ghosts that are listed should not be ghosts
625
vf.add_lines_with_ghosts('notbase', ['base', 'stillghost'], [])
626
except NotImplementedError:
628
vf.add_lines('base', [], [])
629
vf.fix_parents('notbase', ['base', 'stillghost'])
630
self.assertEqual(['base'], vf.get_parents('notbase'))
631
# open again, check it stuck.
633
self.assertEqual(['base'], vf.get_parents('notbase'))
634
# and check the ghosts
635
self.assertEqual(['base', 'stillghost'],
636
vf.get_parents_with_ghosts('notbase'))
638
600
def test_add_lines_with_ghosts(self):
639
601
# some versioned file formats allow lines to be added with parent
640
602
# information that is > than that in the format. Formats that do
661
623
self.assertEqual(['notbxbfse'], vf.get_ancestry('notbxbfse'))
662
624
self.assertEqual([], vf.get_parents('notbxbfse'))
663
625
self.assertEqual({'notbxbfse':()}, vf.get_graph())
664
self.assertFalse(self.callDeprecated([osutils._revision_id_warning],
665
vf.has_version, parent_id_unicode))
666
626
self.assertFalse(vf.has_version(parent_id_utf8))
667
627
# we have _with_ghost apis to give us ghost information.
668
628
self.assertEqual([parent_id_utf8, 'notbxbfse'], vf.get_ancestry_with_ghosts(['notbxbfse']))
669
629
self.assertEqual([parent_id_utf8], vf.get_parents_with_ghosts('notbxbfse'))
670
630
self.assertEqual({'notbxbfse':[parent_id_utf8]}, vf.get_graph_with_ghosts())
671
self.assertTrue(self.callDeprecated([osutils._revision_id_warning],
672
vf.has_ghost, parent_id_unicode))
673
631
self.assertTrue(vf.has_ghost(parent_id_utf8))
674
632
# if we add something that is a ghost of another, it should correct the
675
633
# results of the prior apis
676
self.callDeprecated([osutils._revision_id_warning],
677
vf.add_lines, parent_id_unicode, [], [])
634
vf.add_lines(parent_id_utf8, [], [])
678
635
self.assertEqual([parent_id_utf8, 'notbxbfse'], vf.get_ancestry(['notbxbfse']))
679
636
self.assertEqual([parent_id_utf8], vf.get_parents('notbxbfse'))
680
637
self.assertEqual({parent_id_utf8:(),
681
638
'notbxbfse':(parent_id_utf8, ),
684
self.assertTrue(self.callDeprecated([osutils._revision_id_warning],
685
vf.has_version, parent_id_unicode))
686
641
self.assertTrue(vf.has_version(parent_id_utf8))
687
642
# we have _with_ghost apis to give us ghost information.
688
self.assertEqual([parent_id_utf8, 'notbxbfse'], vf.get_ancestry_with_ghosts(['notbxbfse']))
643
self.assertEqual([parent_id_utf8, 'notbxbfse'],
644
vf.get_ancestry_with_ghosts(['notbxbfse']))
689
645
self.assertEqual([parent_id_utf8], vf.get_parents_with_ghosts('notbxbfse'))
690
646
self.assertEqual({parent_id_utf8:[],
691
647
'notbxbfse':[parent_id_utf8],
693
649
vf.get_graph_with_ghosts())
694
self.assertFalse(self.callDeprecated([osutils._revision_id_warning],
695
vf.has_ghost, parent_id_unicode))
696
650
self.assertFalse(vf.has_ghost(parent_id_utf8))
698
652
def test_add_lines_with_ghosts_after_normal_revs(self):