~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/test_weave.py

  • Committer: Aaron Bentley
  • Date: 2005-10-27 23:14:48 UTC
  • mfrom: (1185.16.130)
  • mto: (1185.25.1)
  • mto: This revision was merged to the branch mainline in revision 1491.
  • Revision ID: abentley@panoramicfeedback.com-20051027231448-ba0ae9cde819edc9
MergeĀ fromĀ mainline

Show diffs side-by-side

added added

removed removed

Lines of Context:
59
59
            self.log('         %r' % k._parents)
60
60
            self.log('         %r' % k2._parents)
61
61
            self.log('')
62
 
 
63
 
            
64
62
            self.fail('read/write check failed')
65
 
        
66
 
        
 
63
 
 
64
 
 
65
class WeaveContains(TestBase):
 
66
    """Weave __contains__ operator"""
 
67
    def runTest(self):
 
68
        k = Weave()
 
69
        self.assertFalse('foo' in k)
 
70
        k.add('foo', [], TEXT_1)
 
71
        self.assertTrue('foo' in k)
67
72
 
68
73
 
69
74
class Easy(TestBase):
876
881
        eq = self.assertEquals
877
882
        eq(sorted(wa.iter_names()), ['v1', 'v2', 'v3', 'x1',])
878
883
        eq(wa.get_text('x1'), 'line from x1\n')
879
 
 
880
 
    def test_reweave_with_empty(self):
881
 
        wb = Weave()
882
 
        wr = reweave(self.weave1, wb)
883
 
        eq = self.assertEquals
884
 
        eq(sorted(wr.iter_names()), ['v1', 'v2', 'v3'])
885
 
        eq(wr.get_lines('v3'), ['hello\n', 'cruel\n', 'world\n'])
886
 
        self.weave1.reweave(wb)
887
 
        self.assertEquals(wr, self.weave1)
888
 
 
889
 
    def test_join_with_ghosts_raises_parent_mismatch(self):
890
 
        wa = self.weave1.copy()
891
 
        wb = Weave()
892
 
        wb.add('x1', [], ['line from x1\n'])
893
 
        wb.add('v1', [], ['hello\n'])
894
 
        wb.add('v2', ['v1', 'x1'], ['hello\n', 'world\n'])
895
 
        self.assertRaises(errors.WeaveParentMismatch, wa.join, wb)
896
 
 
897
 
    def test_reweave_with_ghosts(self):
898
 
        """Join that inserts parents of an existing revision.
899
 
 
900
 
        This can happen when merging from another branch who
901
 
        knows about revisions the destination does not.  In 
902
 
        this test the second weave knows of an additional parent of 
903
 
        v2.  Any revisions which are in common still have to have the 
904
 
        same text."""
905
 
        wa = self.weave1.copy()
906
 
        wb = Weave()
907
 
        wb.add('x1', [], ['line from x1\n'])
908
 
        wb.add('v1', [], ['hello\n'])
909
 
        wb.add('v2', ['v1', 'x1'], ['hello\n', 'world\n'])
910
 
        wc = reweave(wa, wb)
911
 
        eq = self.assertEquals
912
 
        eq(sorted(wc.iter_names()), ['v1', 'v2', 'v3', 'x1',])
913
 
        eq(wc.get_text('x1'), 'line from x1\n')
914
 
        eq(wc.get_lines('v2'), ['hello\n', 'world\n'])
915
 
        eq(wc.parent_names('v2'), ['v1', 'x1'])
916
 
        self.weave1.reweave(wb)
917
 
        self.assertEquals(wc, self.weave1)
918
 
 
919
 
 
920
 
if __name__ == '__main__':
921
 
    import sys
922
 
    import unittest
923
 
    sys.exit(unittest.main())
924