~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/smart/medium.py

  • Committer: Johan Walles
  • Date: 2009-05-06 05:36:28 UTC
  • mfrom: (4332 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4343.
  • Revision ID: johan.walles@gmail.com-20090506053628-tbf1wz4a0m9t684g
MergeĀ fromĀ upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
43
43
    ui,
44
44
    urlutils,
45
45
    )
46
 
from bzrlib.smart import client, protocol, request, vfs
 
46
from bzrlib.smart import client, protocol
47
47
from bzrlib.transport import ssh
48
48
""")
49
49
 
509
509
        """
510
510
        medium_repr = repr(medium)
511
511
        # Add this medium to the WeakKeyDictionary
512
 
        self.counts[medium] = dict(count=0, vfs_count=0,
513
 
                                   medium_repr=medium_repr)
 
512
        self.counts[medium] = [0, medium_repr]
514
513
        # Weakref callbacks are fired in reverse order of their association
515
514
        # with the referenced object.  So we add a weakref *after* adding to
516
515
        # the WeakKeyDict so that we can report the value from it before the
520
519
    def increment_call_count(self, params):
521
520
        # Increment the count in the WeakKeyDictionary
522
521
        value = self.counts[params.medium]
523
 
        value['count'] += 1
524
 
        request_method = request.request_handlers.get(params.method)
525
 
        if issubclass(request_method, vfs.VfsRequest):
526
 
            value['vfs_count'] += 1
 
522
        value[0] += 1
527
523
 
528
524
    def done(self, ref):
529
525
        value = self.counts[ref]
530
 
        count, vfs_count, medium_repr = (
531
 
            value['count'], value['vfs_count'], value['medium_repr'])
 
526
        count, medium_repr = value
532
527
        # In case this callback is invoked for the same ref twice (by the
533
528
        # weakref callback and by the atexit function), set the call count back
534
529
        # to 0 so this item won't be reported twice.
535
 
        value['count'] = 0
536
 
        value['vfs_count'] = 0
 
530
        value[0] = 0
537
531
        if count != 0:
538
 
            trace.note('HPSS calls: %d (%d vfs) %s',
539
 
                       count, vfs_count, medium_repr)
 
532
            trace.note('HPSS calls: %d %s', count, medium_repr)
540
533
 
541
534
    def flush_all(self):
542
535
        for ref in list(self.counts.keys()):