/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/index.py

  • Committer: John Arbash Meinel
  • Date: 2010-03-05 17:56:55 UTC
  • mto: This revision was merged to the branch mainline in revision 5116.
  • Revision ID: john@arbash-meinel.com-20100305175655-06ypovp1vq6ngclt
Actually implement offset support for GraphIndex.

I don't think it is strictly needed, but bzr-search would want it
for old-format data. Plus it felt a bit weird to arbitrarily
abort.

Show diffs side-by-side

added added

removed removed

Lines of Context:
419
419
        # The number of bytes we've read so far in trying to process this file
420
420
        self._bytes_read = 0
421
421
        self._base_offset = offset
422
 
        if offset != 0:
423
 
            raise NotImplementedError('GraphIndex(offset) must be 0')
424
422
 
425
423
    def __eq__(self, other):
426
424
        """Equal when self and other were created with the same parameters."""
449
447
            mutter('Reading entire index %s', self._transport.abspath(self._name))
450
448
        if stream is None:
451
449
            stream = self._transport.get(self._name)
 
450
            if self._base_offset != 0:
 
451
                # This is wasteful, but it is better than dealing with
 
452
                # adjusting all the offsets, etc.
 
453
                stream = StringIO(stream.read()[self._base_offset:])
452
454
        self._read_prefix(stream)
453
455
        self._expected_elements = 3 + self._key_length
454
456
        line_count = 0
1195
1197
            self._buffer_all()
1196
1198
            return
1197
1199
 
 
1200
        base_offset = self._base_offset
 
1201
        if base_offset != 0:
 
1202
            # Rewrite the ranges for the offset
 
1203
            readv_ranges = [(start+base_offset, size)
 
1204
                            for start, size in readv_ranges]
1198
1205
        readv_data = self._transport.readv(self._name, readv_ranges, True,
1199
 
            self._size)
 
1206
            self._size + self._base_offset)
1200
1207
        # parse
1201
1208
        for offset, data in readv_data:
 
1209
            offset -= base_offset
1202
1210
            self._bytes_read += len(data)
 
1211
            if offset < 0:
 
1212
                # transport.readv() expanded to extra data which isn't part of
 
1213
                # this index
 
1214
                data = data[-offset:]
 
1215
                offset = 0
1203
1216
            if offset == 0 and len(data) == self._size:
1204
1217
                # We read the whole range, most likely because the
1205
1218
                # Transport upcast our readv ranges into one long request