~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/hooks.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-08-03 04:57:59 UTC
  • mfrom: (6042.1.2 fix-log-2)
  • Revision ID: pqm@pqm.ubuntu.com-20110803045759-1lrr8eymve8ofldr
(mbp) Log levels are no longer reset to what the log formatter supports (bug
 747958) (Thomi Richards)

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
    errors,
31
31
    pyutils,
32
32
    )
33
 
from bzrlib.i18n import gettext
34
33
""")
35
34
 
36
35
 
71
70
 
72
71
_builtin_known_hooks = (
73
72
    ('bzrlib.branch', 'Branch.hooks', 'BranchHooks'),
74
 
    ('bzrlib.controldir', 'ControlDir.hooks', 'ControlDirHooks'),
 
73
    ('bzrlib.bzrdir', 'BzrDir.hooks', 'BzrDirHooks'),
75
74
    ('bzrlib.commands', 'Command.hooks', 'CommandHooks'),
76
75
    ('bzrlib.config', 'ConfigHooks', '_ConfigHooks'),
77
76
    ('bzrlib.info', 'hooks', 'InfoHooks'),
127
126
        """
128
127
        dict.__init__(self)
129
128
        self._callable_names = {}
130
 
        self._lazy_callable_names = {}
131
129
        self._module = module
132
130
        self._member_name = member_name
133
131
 
197
195
        the code names are rarely meaningful for end users and this is not
198
196
        intended for debugging.
199
197
        """
200
 
        name = self._callable_names.get(a_callable, None)
201
 
        if name is None and a_callable is not None:
202
 
            name = self._lazy_callable_names.get((a_callable.__module__,
203
 
                                                  a_callable.__name__),
204
 
                                                 None)
205
 
        if name is None:
206
 
            return 'No hook name'
207
 
        return name
208
 
 
 
198
        return self._callable_names.get(a_callable, "No hook name")
209
199
 
210
200
    def install_named_hook_lazy(self, hook_name, callable_module,
211
201
        callable_member, name):
230
220
                self)
231
221
        else:
232
222
            hook_lazy(callable_module, callable_member, name)
233
 
        if name is not None:
234
 
            self.name_hook_lazy(callable_module, callable_member, name)
235
223
 
236
224
    def install_named_hook(self, hook_name, a_callable, name):
237
225
        """Install a_callable in to the hook hook_name, and label it name.
277
265
        """Associate name with a_callable to show users what is running."""
278
266
        self._callable_names[a_callable] = name
279
267
 
280
 
    def name_hook_lazy(self, callable_module, callable_member, callable_name):
281
 
        self._lazy_callable_names[(callable_module, callable_member)]= \
282
 
            callable_name
283
 
 
284
268
 
285
269
class HookPoint(object):
286
270
    """A single hook that clients can register to be called back when it fires.
326
310
            introduced_string = _format_version_tuple(self.introduced)
327
311
        else:
328
312
            introduced_string = 'unknown'
329
 
        strings.append(gettext('Introduced in: %s') % introduced_string)
 
313
        strings.append('Introduced in: %s' % introduced_string)
330
314
        if self.deprecated:
331
315
            deprecated_string = _format_version_tuple(self.deprecated)
332
 
            strings.append(gettext('Deprecated in: %s') % deprecated_string)
 
316
            strings.append('Deprecated in: %s' % deprecated_string)
333
317
        strings.append('')
334
318
        strings.extend(textwrap.wrap(self.__doc__,
335
319
            break_long_words=False))