/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/transport/trace.py

  • Committer: Vincent Ladeuil
  • Date: 2010-01-25 15:55:48 UTC
  • mto: (4985.1.4 add-attr-cleanup)
  • mto: This revision was merged to the branch mainline in revision 4988.
  • Revision ID: v.ladeuil+lp@free.fr-20100125155548-0l352pujvt5bzl5e
Deploy addAttrCleanup on the whole test suite.

Several use case worth mentioning:

- setting a module or any other object attribute is the majority
by far. In some cases the setting itself is deferred but most of
the time we want to set at the same time we add the cleanup.

- there multiple occurrences of protecting hooks or ui factory
which are now useless (the test framework takes care of that now),

- there was some lambda uses that can now be avoided.

That first cleanup already simplifies things a lot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
43
43
 
44
44
        _decorated is a private parameter for cloning.
45
45
        """
46
 
        super(TransportTraceDecorator, self).__init__(url, _decorated)
 
46
        TransportDecorator.__init__(self, url, _decorated)
47
47
        if _from_transport is None:
48
48
            # newly created
49
49
            self._activity = []
169
169
        self._activity.append(operation_tuple)
170
170
 
171
171
 
 
172
class TraceServer(DecoratorServer):
 
173
    """Server for the TransportTraceDecorator for testing with."""
 
174
 
 
175
    def get_decorator_class(self):
 
176
        return TransportTraceDecorator
 
177
 
 
178
 
172
179
def get_test_permutations():
173
180
    """Return the permutations to be used in testing."""
174
 
    from bzrlib.tests import test_server
175
 
    return [(TransportTraceDecorator, test_server.TraceServer)]
 
181
    return [(TransportTraceDecorator, TraceServer)]