~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_weave.py

  • Committer: Robert Collins
  • Date: 2006-02-22 10:35:05 UTC
  • mto: (1594.2.4 integration)
  • mto: This revision was merged to the branch mainline in revision 1596.
  • Revision ID: robertc@robertcollins.net-20060222103505-bddb211d353f2543
Merge in a variation of the versionedfile api from versioned-file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
121
121
        k.add('text0', [], 'text0')
122
122
        self.assertEqual('34dc0e430c642a26c3dd1c2beb7a8b4f4445eb79',
123
123
                         k.get_sha1('text0'))
124
 
        self.assertRaises(errors.WeaveRevisionNotPresent,
 
124
        self.assertRaises(errors.RevisionNotPresent,
125
125
                          k.get_sha1, 0)
126
 
        self.assertRaises(errors.WeaveRevisionNotPresent,
 
126
        self.assertRaises(errors.RevisionNotPresent,
127
127
                          k.get_sha1, 'text1')
128
128
                        
129
129
 
152
152
    def runTest(self):
153
153
        k = Weave()
154
154
        idx = k.add('text0', [], TEXT_0)
155
 
        self.assertRaises(WeaveError,
 
155
        self.assertRaises(errors.RevisionAlreadyPresent,
156
156
                          k.add,
157
157
                          'text0',
158
158
                          [],
159
159
                          ['not the same text'])
160
 
        self.assertRaises(WeaveError,
 
160
        self.assertRaises(errors.RevisionAlreadyPresent,
161
161
                          k.add,
162
162
                          'text0',
163
163
                          [12],         # not the right parents
517
517
    """Weave with two diverged texts based on version 0.
518
518
    """
519
519
    def runTest(self):
 
520
        # FIXME make the weave, dont poke at it.
520
521
        k = Weave()
521
522
 
 
523
        k._names = ['0', '1', '2']
522
524
        k._parents = [frozenset(),
523
525
                frozenset([0]),
524
526
                frozenset([0]),
550
552
                          "alternative second line"])
551
553
 
552
554
        self.assertEqual(list(k.inclusions([2])),
553
 
                         [0, 2])
 
555
                         ['0', '2'])
554
556
 
555
557
 
556
558
class ReplaceLine(TestBase):
597
599
                          ])
598
600
 
599
601
        self.assertEqual(list(k.inclusions([3])),
600
 
                         [0, 1, 2, 3])
 
602
                         ['text0', 'text1', 'text2', 'merge'])
601
603
 
602
604
        self.log('k._weave=' + pformat(k._weave))
603
605
 
638
640
        k.add([1], ['aaa', 'ccc', 'bbb', '222'])
639
641
 
640
642
 
641
 
class AutoMerge(TestBase):
642
 
    def runTest(self):
643
 
        k = Weave()
644
 
 
645
 
        texts = [['header', 'aaa', 'bbb'],
646
 
                 ['header', 'aaa', 'line from 1', 'bbb'],
647
 
                 ['header', 'aaa', 'bbb', 'line from 2', 'more from 2'],
648
 
                 ]
649
 
 
650
 
        k.add('text0', [], texts[0])
651
 
        k.add('text1', [0], texts[1])
652
 
        k.add('text2', [0], texts[2])
653
 
 
654
 
        self.log('k._weave=' + pformat(k._weave))
655
 
 
656
 
        m = list(k.mash_iter([0, 1, 2]))
657
 
 
658
 
        self.assertEqual(m,
659
 
                         ['header', 'aaa',
660
 
                          'line from 1',
661
 
                          'bbb',
662
 
                          'line from 2', 'more from 2'])
663
 
 
664
 
 
665
643
class Khayyam(TestBase):
666
644
    """Test changes to multi-line texts, and read/write"""
667
 
    def runTest(self):
 
645
 
 
646
    def test_multi_line_merge(self):
668
647
        rawtexts = [
669
648
            """A Book of Verses underneath the Bough,
670
649
            A Jug of Wine, a Loaf of Bread, -- and Thou