~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/transport/trace.py

  • Committer: Robert Collins
  • Date: 2009-03-16 07:44:05 UTC
  • mto: This revision was merged to the branch mainline in revision 4149.
  • Revision ID: robertc@robertcollins.net-20090316074405-t9guvf13rj4mlhuk
More test fallout, but all caught now.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
"""Implementation of Transport that traces transport operations.
18
18
 
20
20
and then delegates it.
21
21
"""
22
22
 
23
 
from bzrlib.transport import decorator
24
 
 
25
 
 
26
 
class TransportTraceDecorator(decorator.TransportDecorator):
 
23
from bzrlib.transport.decorator import TransportDecorator, DecoratorServer
 
24
 
 
25
 
 
26
class TransportTraceDecorator(TransportDecorator):
27
27
    """A tracing decorator for Transports.
28
28
 
29
29
    Calls that potentially perform IO are logged to self._activity. The
33
33
    Not all operations are logged at this point, if you need an unlogged
34
34
    operation please add a test to the tests of this transport, for the logging
35
35
    of the operation you want logged.
36
 
 
37
 
    See also TransportLogDecorator, that records a machine-readable log in 
38
 
    memory for eg testing.
39
36
    """
40
37
 
41
38
    def __init__(self, url, _decorated=None, _from_transport=None):
43
40
 
44
41
        _decorated is a private parameter for cloning.
45
42
        """
46
 
        super(TransportTraceDecorator, self).__init__(url, _decorated)
 
43
        TransportDecorator.__init__(self, url, _decorated)
47
44
        if _from_transport is None:
48
45
            # newly created
49
46
            self._activity = []
129
126
 
130
127
    def readv(self, relpath, offsets, adjust_for_latency=False,
131
128
        upper_limit=None):
132
 
        # we override at the readv() level rather than _readv() so that any
133
 
        # latency adjustments will be done by the underlying transport
 
129
        """See Transport.readv."""
134
130
        self._trace(('readv', relpath, offsets, adjust_for_latency,
135
131
            upper_limit))
136
132
        return self._decorated.readv(relpath, offsets, adjust_for_latency,
169
165
        self._activity.append(operation_tuple)
170
166
 
171
167
 
 
168
class TraceServer(DecoratorServer):
 
169
    """Server for the TransportTraceDecorator for testing with."""
 
170
 
 
171
    def get_decorator_class(self):
 
172
        return TransportTraceDecorator
 
173
 
 
174
 
172
175
def get_test_permutations():
173
176
    """Return the permutations to be used in testing."""
174
 
    from bzrlib.tests import test_server
175
 
    return [(TransportTraceDecorator, test_server.TraceServer)]
 
177
    return [(TransportTraceDecorator, TraceServer)]