~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/knit.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-09-23 21:08:26 UTC
  • mfrom: (2849.1.1 index)
  • Revision ID: pqm@pqm.ubuntu.com-20070923210826-t3ymvo1l68z96in1
(robertc) Tweak index -Devil tracing.

Show diffs side-by-side

added added

removed removed

Lines of Context:
104
104
from bzrlib.osutils import (
105
105
    contains_whitespace,
106
106
    contains_linebreaks,
107
 
    sha_string,
108
107
    sha_strings,
109
108
    )
110
109
from bzrlib.symbol_versioning import DEPRECATED_PARAMETER, deprecated_passed
855
854
 
856
855
        Any versions not present will be converted into ghosts.
857
856
        """
858
 
        # first thing, if the content is something we don't need to store, find
859
 
        # that out.
860
 
        line_bytes = ''.join(lines)
861
 
        digest = sha_string(line_bytes)
862
 
        if nostore_sha == digest:
863
 
            raise errors.ExistingContent
 
857
        #  461    0   6546.0390     43.9100   bzrlib.knit:489(_add)
 
858
        # +400    0    889.4890    418.9790   +bzrlib.knit:192(lower_fulltext)
 
859
        # +461    0   1364.8070    108.8030   +bzrlib.knit:996(add_record)
 
860
        # +461    0    193.3940     41.5720   +bzrlib.knit:898(add_version)
 
861
        # +461    0    134.0590     18.3810   +bzrlib.osutils:361(sha_strings)
 
862
        # +461    0     36.3420     15.4540   +bzrlib.knit:146(make)
 
863
        # +1383   0      8.0370      8.0370   +<len>
 
864
        # +61     0     13.5770      7.9190   +bzrlib.knit:199(lower_line_delta)
 
865
        # +61     0    963.3470      7.8740   +bzrlib.knit:427(_get_content)
 
866
        # +61     0    973.9950      5.2950   +bzrlib.knit:136(line_delta)
 
867
        # +61     0   1918.1800      5.2640   +bzrlib.knit:359(_merge_annotations)
864
868
 
865
869
        present_parents = []
866
870
        if parent_texts is None:
875
879
             present_parents[0] != parents[0])):
876
880
            delta = False
877
881
 
878
 
        text_length = len(line_bytes)
 
882
        digest = sha_strings(lines)
 
883
        if nostore_sha == digest:
 
884
            raise errors.ExistingContent
 
885
        text_length = sum(map(len, lines))
879
886
        options = []
880
887
        if lines:
881
888
            if lines[-1][-1] != '\n':
901
908
        if delta:
902
909
            options.append('line-delta')
903
910
            store_lines = self.factory.lower_line_delta(delta_hunks)
904
 
            size, bytes = self._data._record_to_data(version_id, digest,
905
 
                store_lines)
906
911
        else:
907
912
            options.append('fulltext')
908
 
            # get mixed annotation + content and feed it into the
909
 
            # serialiser.
910
913
            store_lines = self.factory.lower_fulltext(content)
911
 
            size, bytes = self._data._record_to_data(version_id, digest,
912
 
                store_lines)
913
914
 
914
 
        access_memo = self._data.add_raw_records([size], bytes)[0]
 
915
        access_memo = self._data.add_record(version_id, digest, store_lines)
915
916
        self._index.add_versions(
916
 
            ((version_id, options, access_memo, parents),),
917
 
            random_id=random_id)
 
917
            ((version_id, options, access_memo, parents),), random_id=random_id)
918
918
        return digest, text_length, content
919
919
 
920
920
    def check(self, progress_bar=None):
2005
2005
        """
2006
2006
        return self._access.add_raw_records(sizes, raw_data)
2007
2007
        
 
2008
    def add_record(self, version_id, digest, lines):
 
2009
        """Write new text record to disk. 
 
2010
        
 
2011
        Returns index data for retrieving it later, as per add_raw_records.
 
2012
        """
 
2013
        size, bytes = self._record_to_data(version_id, digest, lines)
 
2014
        result = self.add_raw_records([size], bytes)
 
2015
        if self._do_cache:
 
2016
            self._cache[version_id] = bytes
 
2017
        return result[0]
 
2018
 
2008
2019
    def _parse_record_header(self, version_id, raw_data):
2009
2020
        """Parse a record header for consistency.
2010
2021