~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/protocol.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-08-08 05:55:16 UTC
  • mfrom: (2683.1.1 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20070808055516-ml9ucjsb4idmpmww
(robertc) Remove the new FileNames class as it is redundant with a trivial no-refs, no-value index. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
client and server.
19
19
"""
20
20
 
 
21
 
21
22
from cStringIO import StringIO
22
 
import time
23
23
 
24
24
from bzrlib import debug
25
25
from bzrlib import errors
300
300
        """
301
301
        self._request = request
302
302
        self._body_buffer = None
303
 
        self._request_start_time = None
304
303
 
305
304
    def call(self, *args):
306
305
        if 'hpss' in debug.debug_flags:
307
 
            mutter('hpss call:   %s', repr(args)[1:-1])
308
 
            self._request_start_time = time.time()
 
306
            mutter('hpss call:   %r', args)
309
307
        self._write_args(args)
310
308
        self._request.finished_writing()
311
309
 
315
313
        After calling this, call read_response_tuple to find the result out.
316
314
        """
317
315
        if 'hpss' in debug.debug_flags:
318
 
            mutter('hpss call w/body: %s (%r...)', repr(args)[1:-1], body[:20])
319
 
            mutter('              %d bytes', len(body))
320
 
            self._request_start_time = time.time()
 
316
            mutter('hpss call w/body: %r (%r...)', args, body[:20])
321
317
        self._write_args(args)
322
318
        bytes = self._encode_bulk_data(body)
323
319
        self._request.accept_bytes(bytes)
330
326
        each pair are separated by a comma, and no trailing \n is emitted.
331
327
        """
332
328
        if 'hpss' in debug.debug_flags:
333
 
            mutter('hpss call w/readv: %s', repr(args)[1:-1])
334
 
            self._request_start_time = time.time()
 
329
            mutter('hpss call w/readv: %r', args)
335
330
        self._write_args(args)
336
331
        readv_bytes = self._serialise_offsets(body)
337
332
        bytes = self._encode_bulk_data(readv_bytes)
338
333
        self._request.accept_bytes(bytes)
339
334
        self._request.finished_writing()
340
 
        if 'hpss' in debug.debug_flags:
341
 
            mutter('              %d bytes in readv request', len(readv_bytes))
342
335
 
343
336
    def cancel_read_body(self):
344
337
        """After expecting a body, a response code may indicate one otherwise.
356
349
        """
357
350
        result = self._recv_tuple()
358
351
        if 'hpss' in debug.debug_flags:
359
 
            if self._request_start_time is not None:
360
 
                mutter('   result:   %6.3fs  %s',
361
 
                       time.time() - self._request_start_time,
362
 
                       repr(result)[1:-1])
363
 
                self._request_start_time = None
364
 
            else:
365
 
                mutter('   result:   %s', repr(result)[1:-1])
 
352
            mutter('hpss result: %r', result)
366
353
        if not expect_body:
367
354
            self._request.finished_reading()
368
355
        return result
384
371
        self._request.finished_reading()
385
372
        self._body_buffer = StringIO(_body_decoder.read_pending_data())
386
373
        # XXX: TODO check the trailer result.
387
 
        if 'hpss' in debug.debug_flags:
388
 
            mutter('              %d body bytes read',
389
 
                   len(self._body_buffer.getvalue()))
390
374
        return self._body_buffer.read(count)
391
375
 
392
376
    def _recv_tuple(self):