/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_versionedfile.py

  • Committer: Daniel Watkins
  • Date: 2007-11-06 09:33:05 UTC
  • mfrom: (2967 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2993.
  • Revision ID: d.m.watkins@warwick.ac.uk-20071106093305-zfef3c0jbcvunnuz
Merged bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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'])
357
356
        
598
597
        self.assertTrue(lines['child\n'] > 0)
599
598
        self.assertTrue(lines['otherchild\n'] > 0)
600
599
 
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.
607
 
        vf = self.get_file()
608
 
        vf.add_lines('notbase', [], [])
609
 
        vf.add_lines('base', [], [])
610
 
        try:
611
 
            vf.fix_parents('notbase', ['base'])
612
 
        except NotImplementedError:
613
 
            return
614
 
        self.assertEqual(['base'], vf.get_parents('notbase'))
615
 
        # open again, check it stuck.
616
 
        vf = self.get_file()
617
 
        self.assertEqual(['base'], vf.get_parents('notbase'))
618
 
 
619
 
    def test_fix_parents_with_ghosts(self):
620
 
        # when fixing parents, ghosts that are listed should not be ghosts
621
 
        # anymore.
622
 
        vf = self.get_file()
623
 
 
624
 
        try:
625
 
            vf.add_lines_with_ghosts('notbase', ['base', 'stillghost'], [])
626
 
        except NotImplementedError:
627
 
            return
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.
632
 
        vf = self.get_file()
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'))
637
 
 
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, ),
682
639
                          },
683
640
                         vf.get_graph())
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],
692
648
                          },
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))
697
651
 
698
652
    def test_add_lines_with_ghosts_after_normal_revs(self):
726
680
                          'base',
727
681
                          [],
728
682
                          [])
729
 
        self.assertRaises(errors.ReadOnlyError, vf.fix_parents, 'base', [])
730
683
        self.assertRaises(errors.ReadOnlyError, vf.join, 'base')
731
684
        self.assertRaises(errors.ReadOnlyError, vf.clone_text, 'base', 'bar', ['foo'])
732
685