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

  • Committer: Martin Pool
  • Date: 2009-07-01 07:04:47 UTC
  • mto: This revision was merged to the branch mainline in revision 4502.
  • Revision ID: mbp@sourcefrog.net-20090701070447-6o6c4wxz74omclyv
Add test for TransportLogDecorator handling of readv

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007, 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2007, 2009 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
169
169
    # gradually consume the readv result.
170
170
 
171
171
    def __init__(self, readv_result):
172
 
        """Construct a new ReadVFile wrapper.
173
 
 
174
 
        :seealso: make_readv_reader
175
 
 
176
 
        :param readv_result: the most recent readv result - list or generator
177
 
        """
178
 
        # readv can return a sequence or an iterator, but we require an
179
 
        # iterator to know how much has been consumed.
180
 
        readv_result = iter(readv_result)
181
172
        self.readv_result = readv_result
 
173
        # the most recent readv result block
182
174
        self._string = None
183
175
 
184
176
    def _next(self):
192
184
        self._next()
193
185
        result = self._string.read(length)
194
186
        if len(result) < length:
195
 
            raise errors.BzrError('wanted %d bytes but next '
196
 
                'hunk only contains %d: %r...' %
197
 
                (length, len(result), result[:20]))
 
187
            raise errors.BzrError('request for too much data from a readv hunk.')
198
188
        return result
199
189
 
200
190
    def readline(self):
202
192
        self._next()
203
193
        result = self._string.readline()
204
194
        if self._string.tell() == self._string_length and result[-1] != '\n':
205
 
            raise errors.BzrError('short readline in the readvfile hunk: %r'
206
 
                % (result, ))
 
195
            raise errors.BzrError('short readline in the readvfile hunk.')
207
196
        return result
208
197
 
209
198