~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/test_weave.py

  • Committer: Robert Collins
  • Date: 2005-10-06 22:15:52 UTC
  • mfrom: (1185.13.2)
  • mto: This revision was merged to the branch mainline in revision 1420.
  • Revision ID: robertc@robertcollins.net-20051006221552-9b15c96fa504e0ad
mergeĀ fromĀ upstream

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
 
 
862
    def test_join_unordered(self):
 
863
        """Join weaves where indexes differ.
 
864
        
 
865
        The source weave contains a different version at index 0."""
 
866
        wa = self.weave1.copy()
 
867
        wb = Weave()
 
868
        wb.add('x1', [], ['line from x1\n'])
 
869
        wb.add('v1', [], ['hello\n'])
 
870
        wb.add('v2', ['v1'], ['hello\n', 'world\n'])
 
871
        wa.join(wb)
 
872
        eq = self.assertEquals
 
873
        eq(sorted(wa.iter_names()), ['v1', 'v2', 'v3', 'x1',])
 
874
        eq(wa.get_text('x1'), 'line from x1\n')
 
875
 
 
876
    def test_join_with_ghosts(self):
 
877
        """Join that inserts parents of an existing revision.
 
878
 
 
879
        This can happen when merging from another branch who
 
880
        knows about revisions the destination does not.  In 
 
881
        this test the second weave knows of an additional parent of 
 
882
        v2.  Any revisions which are in common still have to have the 
 
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')
 
894
 
843
895
 
844
896
if __name__ == '__main__':
845
897
    import sys