~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_weave.py

  • Committer: Robert Collins
  • Date: 2007-09-03 02:58:58 UTC
  • mto: (2592.3.122 repository)
  • mto: This revision was merged to the branch mainline in revision 2791.
  • Revision ID: robertc@robertcollins.net-20070903025858-k2pxq3qz6ulhhtgq
 * The ``add_lines`` methods on ``VersionedFile`` implementations has changed
   its return value to include the sha1 and length of the inserted text. This
   allows the avoidance of double-sha1 calculations during commit.
   (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
 
40
40
 
41
41
class TestBase(TestCase):
 
42
 
42
43
    def check_read_write(self, k):
43
44
        """Check the weave k can be written & re-read."""
44
45
        from tempfile import TemporaryFile
75
76
        k = Weave()
76
77
 
77
78
 
78
 
class StoreText(TestBase):
79
 
    """Store and retrieve a simple text."""
80
 
 
81
 
    def test_storing_text(self):
82
 
        k = Weave()
83
 
        idx = k.add_lines('text0', [], TEXT_0)
84
 
        self.assertEqual(k.get_lines(idx), TEXT_0)
85
 
        self.assertEqual(idx, 0)
86
 
 
87
 
 
88
79
class AnnotateOne(TestBase):
89
80
    def runTest(self):
90
81
        k = Weave()
93
84
                         [('text0', TEXT_0[0])])
94
85
 
95
86
 
96
 
class StoreTwo(TestBase):
97
 
    def runTest(self):
98
 
        k = Weave()
99
 
 
100
 
        idx = k.add_lines('text0', [], TEXT_0)
101
 
        self.assertEqual(idx, 0)
102
 
 
103
 
        idx = k.add_lines('text1', [], TEXT_1)
104
 
        self.assertEqual(idx, 1)
105
 
 
106
 
        self.assertEqual(k.get_lines(0), TEXT_0)
107
 
        self.assertEqual(k.get_lines(1), TEXT_1)
108
 
 
109
 
 
110
87
class GetSha1(TestBase):
111
88
    def test_get_sha1(self):
112
89
        k = Weave()
133
110
 
134
111
class RepeatedAdd(TestBase):
135
112
    """Add the same version twice; harmless."""
136
 
    def runTest(self):
 
113
 
 
114
    def test_duplicate_add(self):
137
115
        k = Weave()
138
116
        idx = k.add_lines('text0', [], TEXT_0)
139
117
        idx2 = k.add_lines('text0', [], TEXT_0)