~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/knit.py

  • Committer: Andrew Bennetts
  • Date: 2007-11-30 07:45:56 UTC
  • mto: (3053.3.2 integrate-1.0)
  • mto: This revision was merged to the branch mainline in revision 3059.
  • Revision ID: andrew.bennetts@canonical.com-20071130074556-ux7lnmgmx1ouiyi3
Address the rest of the review comments from John and myself.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1535
1535
            return 'line-delta'
1536
1536
 
1537
1537
    def get_options(self, version_id):
1538
 
        """Return a string representing options.
 
1538
        """Return a list representing options.
1539
1539
 
1540
1540
        e.g. ['foo', 'bar']
1541
1541
        """
2080
2080
    def get_raw_records(self, memos_for_retrieval):
2081
2081
        """Get the raw bytes for a records.
2082
2082
 
2083
 
        :param memos_for_retrieval: An iterable containing the (index, pos, 
2084
 
            length) memo for retrieving the bytes. The .knit method ignores
2085
 
            the index as there is always only a single file.
 
2083
        :param memos_for_retrieval: An iterable containing the (thunk_flag,
 
2084
            index, start, end) memo for retrieving the bytes.
2086
2085
        :return: An iterator over the bytes of the records.
2087
2086
        """
2088
2087
        # use a generator for memory friendliness
2089
 
        for index, start, end in memos_for_retrieval:
2090
 
            if index is self.stream_index:
 
2088
        for thunk_flag, version_id, start, end in memos_for_retrieval:
 
2089
            if version_id is self.stream_index:
2091
2090
                yield self.data[start:end]
2092
2091
                continue
2093
2092
            # we have been asked to thunk. This thunking only occurs when
2096
2095
            # We could improve performance here by scanning for where we need
2097
2096
            # to do this and using get_line_list, then interleaving the output
2098
2097
            # as desired. However, for now, this is sufficient.
2099
 
            if (index[:6] != 'thunk:' or
2100
 
                self.orig_factory.__class__ != KnitPlainFactory):
2101
 
                raise errors.KnitCorrupt(self, 'Bad thunk request %r' % index)
2102
 
            version_id = index[6:]
 
2098
            if self.orig_factory.__class__ != KnitPlainFactory:
 
2099
                raise errors.KnitCorrupt(
 
2100
                    self, 'Bad thunk request %r' % version_id)
2103
2101
            lines = self.backing_knit.get_lines(version_id)
2104
2102
            line_bytes = ''.join(lines)
2105
2103
            digest = sha_string(line_bytes)
2175
2173
            raise errors.KnitIndexUnknownMethod(self, options)
2176
2174
 
2177
2175
    def get_options(self, version_id):
2178
 
        """Return a string representing options.
 
2176
        """Return a list representing options.
2179
2177
 
2180
2178
        e.g. ['foo', 'bar']
2181
2179
        """
2189
2187
        """Return details needed to access the version.
2190
2188
        
2191
2189
        _StreamAccess has the data as a big array, so we return slice
2192
 
        coordinates into that (as index_memo's are opaque outside the 
2193
 
        index and matching access class.
 
2190
        coordinates into that (as index_memo's are opaque outside the
 
2191
        index and matching access class).
2194
2192
 
2195
 
        :return: a tuple (None, start, end).
 
2193
        :return: a tuple (thunk_flag, index, start, end).  If thunk_flag is
 
2194
            False, index will be self, otherwise it will be a version id.
2196
2195
        """
2197
2196
        try:
2198
2197
            start, end = self._by_version[version_id][1]
2199
 
            return self, start, end
 
2198
            return False, self, start, end
2200
2199
        except KeyError:
2201
2200
            # Signal to the access object to handle this from the backing knit.
2202
 
            return ('thunk:%s' % version_id, None, None)
 
2201
            return (True, version_id, None, None)
2203
2202
 
2204
2203
    def get_versions(self):
2205
2204
        """Get all the versions in the stream."""