~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/symbol_versioning.py

  • Committer: Martin Pool
  • Date: 2007-10-03 08:06:44 UTC
  • mto: This revision was merged to the branch mainline in revision 2901.
  • Revision ID: mbp@sourcefrog.net-20071003080644-oivy0gkg98sex0ed
Avoid internal error tracebacks on failure to lock on readonly transport (#129701).

Add new LockFailed, which doesn't imply that we failed to get it because of
contention.  Raise this if we fail to create the pending or lock directories
because of Transport errors.

UnlockableTransport is not an internal error.

ReadOnlyLockError has a message which didn't match its name or usage; it's now
deprecated and callers are updated to use LockFailed which is more appropriate.

Add zero_ninetytwo deprecation symbol.

Unify assertMatchesRe with TestCase.assertContainsRe.

When the constructor is deprecated, just say that the class is deprecated, not
the __init__ method - this works better with applyDeprecated in tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
           'zero_eighteen',
40
40
           'zero_ninety',
41
41
           'zero_ninetyone',
 
42
           'zero_ninetytwo',
42
43
           ]
43
44
 
44
45
from warnings import warn
59
60
zero_eighteen = "%s was deprecated in version 0.18."
60
61
zero_ninety = "%s was deprecated in version 0.90."
61
62
zero_ninetyone = "%s was deprecated in version 0.91."
 
63
zero_ninetytwo = "%s was deprecated in version 0.92."
62
64
 
63
65
 
64
66
def set_warning_method(method):
84
86
        have a single %s operator in it. a_callable will be turned into a nice
85
87
        python symbol and then substituted into deprecation_version.
86
88
    """
 
89
    # We also want to handle old-style classes, in particular exception, and
 
90
    # they don't have an im_class attribute.
87
91
    if getattr(a_callable, 'im_class', None) is None:
88
92
        symbol = "%s.%s" % (a_callable.__module__,
89
93
                            a_callable.__name__)
129
133
        
130
134
        def decorated_method(self, *args, **kwargs):
131
135
            """This is the decorated method."""
132
 
            symbol = "%s.%s.%s" % (self.__class__.__module__,
133
 
                                   self.__class__.__name__,
134
 
                                   callable.__name__
135
 
                                   )
 
136
            if callable.__name__ == '__init__':
 
137
                symbol = "%s.%s" % (self.__class__.__module__,
 
138
                                    self.__class__.__name__,
 
139
                                    )
 
140
            else:
 
141
                symbol = "%s.%s.%s" % (self.__class__.__module__,
 
142
                                       self.__class__.__name__,
 
143
                                       callable.__name__
 
144
                                       )
136
145
            warn(deprecation_version % symbol, DeprecationWarning, stacklevel=2)
137
146
            return callable(self, *args, **kwargs)
138
147
        _populate_decorated(callable, deprecation_version, "method",