~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/test_weave.py

  • Committer: Martin Pool
  • Date: 2005-10-06 10:53:12 UTC
  • mto: (1185.13.3)
  • mto: This revision was merged to the branch mainline in revision 1418.
  • Revision ID: mbp@sourcefrog.net-20051006105312-06320dbb986e4bb3
- test that we cannot join weaves with different ancestry

Show diffs side-by-side

added added

removed removed

Lines of Context:
840
840
        eq(wa.get_lines('b1'),
841
841
           ['hello\n', 'pale blue\n', 'world\n'])
842
842
 
 
843
    def test_join_parent_disagreement(self):
 
844
        """Cannot join weaves with different parents for a version."""
 
845
        wa = Weave()
 
846
        wb = Weave()
 
847
        wa.add('v1', [], ['hello\n'])
 
848
        wb.add('v0', [], [])
 
849
        wb.add('v1', ['v0'], ['hello\n'])
 
850
        self.assertRaises(WeaveError,
 
851
                          wa.join, wb)
 
852
 
 
853
    def test_join_text_disagreement(self):
 
854
        """Cannot join weaves with different texts for a version."""
 
855
        wa = Weave()
 
856
        wb = Weave()
 
857
        wa.add('v1', [], ['hello\n'])
 
858
        wb.add('v1', [], ['not\n', 'hello\n'])
 
859
        self.assertRaises(WeaveError,
 
860
                          wa.join, wb)
 
861
 
843
862
    def test_join_unordered(self):
844
863
        """Join weaves where indexes differ.
845
864
        
853
872
        eq = self.assertEquals
854
873
        eq(sorted(wa.iter_names()), ['v1', 'v2', 'v3', 'x1',])
855
874
        eq(wa.get_text('x1'), 'line from x1\n')
856
 
        eq(wa.get_lines('v2'), ['hello\n', 'world\n'])
857
875
 
858
876
    def test_join_with_ghosts(self):
859
877
        """Join that inserts parents of an existing revision.
863
881
        this test the second weave knows of an additional parent of 
864
882
        v2.  Any revisions which are in common still have to have the 
865
883
        same text."""
 
884
        return ###############################
 
885
        wa = self.weave1.copy()
 
886
        wb = Weave()
 
887
        wb.add('x1', [], ['line from x1\n'])
 
888
        wb.add('v1', [], ['hello\n'])
 
889
        wb.add('v2', ['v1', 'x1'], ['hello\n', 'world\n'])
 
890
        wa.join(wb)
 
891
        eq = self.assertEquals
 
892
        eq(sorted(wa.iter_names()), ['v1', 'v2', 'v3', 'x1',])
 
893
        eq(wa.get_text('x1'), 'line from x1\n')
866
894
 
867
895
 
868
896
if __name__ == '__main__':