~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/log.py

(jelmer) Use the absolute_import feature everywhere in bzrlib,
 and add a source test to make sure it's used everywhere. (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007 Canonical Ltd
 
1
# Copyright (C) 2008, 2009, 2010 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
16
16
 
17
17
"""Transport decorator that logs transport operations to .bzr.log."""
18
18
 
 
19
from __future__ import absolute_import
19
20
 
20
21
# see also the transportstats plugin, which gives you some summary information
21
22
# in a machine-readable dump
26
27
import types
27
28
 
28
29
from bzrlib.trace import mutter
29
 
from bzrlib.transport.decorator import (
30
 
    TransportDecorator,
31
 
    )
32
 
from bzrlib.transport.trace import (
33
 
    DecoratorServer,
34
 
    TransportTraceDecorator,
35
 
    )
36
 
 
37
 
 
38
 
 
39
 
 
40
 
class TransportLogDecorator(TransportDecorator):
 
30
from bzrlib.transport import decorator
 
31
 
 
32
 
 
33
class TransportLogDecorator(decorator.TransportDecorator):
41
34
    """Decorator for Transports that logs interesting operations to .bzr.log.
42
35
 
43
36
    In general we want to log things that usually take a network round trip
136
129
        if False:
137
130
            elapsed = time.time() - before
138
131
            if result_len and elapsed > 0:
139
 
                # this is the rate of higher-level data, not the raw network speed
140
 
                mutter("      %9.03fs %8dKB/s" % (elapsed, result_len/elapsed/1024))
 
132
                # this is the rate of higher-level data, not the raw network
 
133
                # speed using base-10 units (see HACKING.txt).
 
134
                mutter("      %9.03fs %8dkB/s"
 
135
                       % (elapsed, result_len/elapsed/1000))
141
136
            else:
142
137
                mutter("      %9.03fs" % (elapsed))
143
138
        return return_result
154
149
        return t
155
150
 
156
151
 
157
 
class LogDecoratorServer(DecoratorServer):
158
 
    """Server for testing."""
159
 
 
160
 
    def get_decorator_class(self):
161
 
        return TransportLogDecorator
162
 
 
163
 
 
164
152
def get_test_permutations():
165
153
    """Return the permutations to be used in testing."""
166
 
    return [(TransportLogDecorator, LogDecoratorServer)]
 
154
    from bzrlib.tests import test_server
 
155
    return [(TransportLogDecorator, test_server.LogDecoratorServer)]