/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_versionedfile.py

  • Committer: Robert Collins
  • Date: 2007-09-27 21:11:38 UTC
  • mfrom: (2871 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2879.
  • Revision ID: robertc@robertcollins.net-20070927211138-ebsu1bo1qz9f1w8n
Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
207
207
            self.assertRaises(errors.RevisionNotPresent, vf.get_lines,
208
208
                version + "2")
209
209
 
210
 
    def test_add_lines_nostoresha(self):
211
 
        """When nostore_sha is supplied using old content raises."""
212
 
        vf = self.get_file()
213
 
        empty_text = ('a', [])
214
 
        sample_text_nl = ('b', ["foo\n", "bar\n"])
215
 
        sample_text_no_nl = ('c', ["foo\n", "bar"])
216
 
        shas = []
217
 
        for version, lines in (empty_text, sample_text_nl, sample_text_no_nl):
218
 
            sha, _, _ = vf.add_lines(version, [], lines)
219
 
            shas.append(sha)
220
 
        # we now have a copy of all the lines in the vf.
221
 
        for sha, (version, lines) in zip(
222
 
            shas, (empty_text, sample_text_nl, sample_text_no_nl)):
223
 
            self.assertRaises(errors.ExistingContent,
224
 
                vf.add_lines, version + "2", [], lines,
225
 
                nostore_sha=sha)
226
 
            # and no new version should have been added.
227
 
            self.assertRaises(errors.RevisionNotPresent, vf.get_lines,
228
 
                version + "2")
229
 
 
230
 
    def test_add_lines_nostoresha(self):
231
 
        """When nostore_sha is supplied using old content raises."""
232
 
        vf = self.get_file()
233
 
        empty_text = ('a', [])
234
 
        sample_text_nl = ('b', ["foo\n", "bar\n"])
235
 
        sample_text_no_nl = ('c', ["foo\n", "bar"])
236
 
        shas = []
237
 
        for version, lines in (empty_text, sample_text_nl, sample_text_no_nl):
238
 
            sha, _, _ = vf.add_lines(version, [], lines)
239
 
            shas.append(sha)
240
 
        # we now have a copy of all the lines in the vf.
241
 
        # is the test applicable to this vf implementation?
242
 
        try:
243
 
            vf.add_lines_with_ghosts('d', [], [])
244
 
        except NotImplementedError:
245
 
            raise TestSkipped("add_lines_with_ghosts is optional")
246
 
        for sha, (version, lines) in zip(
247
 
            shas, (empty_text, sample_text_nl, sample_text_no_nl)):
248
 
            self.assertRaises(errors.ExistingContent,
249
 
                vf.add_lines_with_ghosts, version + "2", [], lines,
250
 
                nostore_sha=sha)
251
 
            # and no new version should have been added.
252
 
            self.assertRaises(errors.RevisionNotPresent, vf.get_lines,
253
 
                version + "2")
254
 
 
255
210
    def test_add_lines_return_value(self):
256
211
        # add_lines should return the sha1 and the text size.
257
212
        vf = self.get_file()