~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/pack.py

  • Committer: Andrew Bennetts
  • Date: 2007-10-22 04:50:25 UTC
  • mfrom: (2916.2.4 streamable-containers)
  • mto: This revision was merged to the branch mainline in revision 3174.
  • Revision ID: andrew.bennetts@canonical.com-20071022045025-s57krf6kiii97bkl
MergeĀ fromĀ streamable-containers.

Show diffs side-by-side

added added

removed removed

Lines of Context:
103
103
            and thus are only suitable for use by a ContainerReader.
104
104
        """
105
105
        current_offset = self.current_offset
 
106
        serialised_record = self._serialise_bytes_record(bytes, names)
 
107
        self.write_func(serialised_record)
 
108
        self.records_written += 1
 
109
        # return a memo of where we wrote data to allow random access.
 
110
        return current_offset, self.current_offset - current_offset
 
111
 
 
112
    def _serialise_bytes_record(self, bytes, names):
106
113
        # Kind marker
107
114
        byte_sections = ["B"]
108
115
        # Length
126
133
        # memory pressure in that case. One possibly improvement here is to
127
134
        # check the size of the content before deciding to join here vs call
128
135
        # write twice.
129
 
        self.write_func(''.join(byte_sections))
130
 
        self.records_written += 1
131
 
        # return a memo of where we wrote data to allow random access.
132
 
        return current_offset, self.current_offset - current_offset
 
136
        return ''.join(byte_sections)
133
137
 
134
138
 
135
139
class ReadVFile(object):
373
377
        # Keep iterating the state machine until it stops consuming bytes from
374
378
        # the buffer.
375
379
        buffer_length = None
376
 
        from bzrlib.trace import mutter
377
380
        while len(self._buffer) != buffer_length:
378
 
            mutter('state: %r, buffer: %r', self._buffer, self._state_handler)
379
381
            buffer_length = len(self._buffer)
380
382
            self._state_handler()
381
383