~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_versionedfile.py

  • Committer: John Arbash Meinel
  • Date: 2009-06-02 20:08:16 UTC
  • mto: This revision was merged to the branch mainline in revision 4469.
  • Revision ID: john@arbash-meinel.com-20090602200816-to10sqhv812zxn5p
Implement add_text for GroupCompressVersionedFiles
The main change is to just use a FulltextContentFactory instead of Chunked.
Should ultimately do much better for memory consumption, etc of initial commit.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1572
1572
            trailing_eol=trailing_eol, nograph=not self.graph,
1573
1573
            left_only=left_only, nokeys=nokeys)
1574
1574
 
1575
 
    def test_add_lines_nostoresha(self):
 
1575
    def _add_content_nostoresha(self, add_lines):
1576
1576
        """When nostore_sha is supplied using old content raises."""
1577
1577
        vf = self.get_versionedfiles()
1578
1578
        empty_text = ('a', [])
1580
1580
        sample_text_no_nl = ('c', ["foo\n", "bar"])
1581
1581
        shas = []
1582
1582
        for version, lines in (empty_text, sample_text_nl, sample_text_no_nl):
1583
 
            sha, _, _ = vf.add_lines(self.get_simple_key(version), [], lines)
 
1583
            if add_lines:
 
1584
                sha, _, _ = vf.add_lines(self.get_simple_key(version), [],
 
1585
                                         lines)
 
1586
            else:
 
1587
                sha, _, _ = vf.add_text(self.get_simple_key(version), [],
 
1588
                                        ''.join(lines))
1584
1589
            shas.append(sha)
1585
1590
        # we now have a copy of all the lines in the vf.
1586
1591
        for sha, (version, lines) in zip(
1589
1594
            self.assertRaises(errors.ExistingContent,
1590
1595
                vf.add_lines, new_key, [], lines,
1591
1596
                nostore_sha=sha)
 
1597
            self.assertRaises(errors.ExistingContent,
 
1598
                vf.add_text, new_key, [], ''.join(lines),
 
1599
                nostore_sha=sha)
1592
1600
            # and no new version should have been added.
1593
1601
            record = vf.get_record_stream([new_key], 'unordered', True).next()
1594
1602
            self.assertEqual('absent', record.storage_kind)
1595
1603
 
 
1604
    def test_add_lines_nostoresha(self):
 
1605
        self._add_content_nostoresha(add_lines=True)
 
1606
 
 
1607
    def test_add_text_nostoresha(self):
 
1608
        self._add_content_nostoresha(add_lines=False)
 
1609
 
1596
1610
    def test_add_lines_return(self):
1597
1611
        files = self.get_versionedfiles()
1598
1612
        # save code by using the stock data insertion helper.