~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/groupcompress.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-06-22 17:11:20 UTC
  • mfrom: (4398.8.10 1.16-commit-fulltext)
  • Revision ID: pqm@pqm.ubuntu.com-20090622171120-fuxez9ylfqpxynqn
(jam) Add VF._add_text and reduce memory overhead during commit (see
        bug #109114)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1008
1008
                                               nostore_sha=nostore_sha))[0]
1009
1009
        return sha1, length, None
1010
1010
 
 
1011
    def _add_text(self, key, parents, text, nostore_sha=None, random_id=False):
 
1012
        """See VersionedFiles.add_text()."""
 
1013
        self._index._check_write_ok()
 
1014
        self._check_add(key, None, random_id, check_content=False)
 
1015
        if text.__class__ is not str:
 
1016
            raise errors.BzrBadParameterUnicode("text")
 
1017
        if parents is None:
 
1018
            # The caller might pass None if there is no graph data, but kndx
 
1019
            # indexes can't directly store that, so we give them
 
1020
            # an empty tuple instead.
 
1021
            parents = ()
 
1022
        # double handling for now. Make it work until then.
 
1023
        length = len(text)
 
1024
        record = FulltextContentFactory(key, parents, None, text)
 
1025
        sha1 = list(self._insert_record_stream([record], random_id=random_id,
 
1026
                                               nostore_sha=nostore_sha))[0]
 
1027
        return sha1, length, None
 
1028
 
1011
1029
    def add_fallback_versioned_files(self, a_versioned_files):
1012
1030
        """Add a source of texts for texts not present in this knit.
1013
1031
 
1521
1539
 
1522
1540
        :return: An iterator over (line, key).
1523
1541
        """
1524
 
        if pb is None:
1525
 
            pb = progress.DummyProgress()
1526
1542
        keys = set(keys)
1527
1543
        total = len(keys)
1528
1544
        # we don't care about inclusions, the caller cares.
1532
1548
            'unordered', True)):
1533
1549
            # XXX: todo - optimise to use less than full texts.
1534
1550
            key = record.key
1535
 
            pb.update('Walking content', key_idx, total)
 
1551
            if pb is not None:
 
1552
                pb.update('Walking content', key_idx, total)
1536
1553
            if record.storage_kind == 'absent':
1537
1554
                raise errors.RevisionNotPresent(key, self)
1538
1555
            lines = osutils.split_lines(record.get_bytes_as('fulltext'))
1539
1556
            for line in lines:
1540
1557
                yield line, key
1541
 
        pb.update('Walking content', total, total)
 
1558
        if pb is not None:
 
1559
            pb.update('Walking content', total, total)
1542
1560
 
1543
1561
    def keys(self):
1544
1562
        """See VersionedFiles.keys."""
1605
1623
                if refs:
1606
1624
                    for ref in refs:
1607
1625
                        if ref:
1608
 
                            raise KnitCorrupt(self,
 
1626
                            raise errors.KnitCorrupt(self,
1609
1627
                                "attempt to add node with parents "
1610
1628
                                "in parentless index.")
1611
1629
                    refs = ()
1668
1686
        if check_present:
1669
1687
            missing_keys = keys.difference(found_keys)
1670
1688
            if missing_keys:
1671
 
                raise RevisionNotPresent(missing_keys.pop(), self)
 
1689
                raise errors.RevisionNotPresent(missing_keys.pop(), self)
1672
1690
 
1673
1691
    def get_parent_map(self, keys):
1674
1692
        """Get a map of the parents of keys.