~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/hooks.py

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007, 2008 Canonical Ltd
 
1
# Copyright (C) 2007-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
18
18
"""Support for plugin hooking logic."""
19
19
from bzrlib import registry
20
20
from bzrlib.lazy_import import lazy_import
21
 
from bzrlib.symbol_versioning import deprecated_method
22
21
lazy_import(globals(), """
23
22
import textwrap
24
23
 
41
40
    'BzrDirHooks')
42
41
known_hooks.register_lazy(('bzrlib.commands', 'Command.hooks'),
43
42
    'bzrlib.commands', 'CommandHooks')
 
43
known_hooks.register_lazy(('bzrlib.info', 'hooks'),
 
44
    'bzrlib.info', 'InfoHooks')
44
45
known_hooks.register_lazy(('bzrlib.lock', 'Lock.hooks'), 'bzrlib.lock',
45
46
    'LockHooks')
 
47
known_hooks.register_lazy(('bzrlib.merge', 'Merger.hooks'), 'bzrlib.merge',
 
48
    'MergeHooks')
46
49
known_hooks.register_lazy(('bzrlib.msgeditor', 'hooks'), 'bzrlib.msgeditor',
47
50
    'MessageEditorHooks')
48
51
known_hooks.register_lazy(('bzrlib.mutabletree', 'MutableTree.hooks'),
54
57
known_hooks.register_lazy(
55
58
    ('bzrlib.version_info_formats.format_rio', 'RioVersionInfoBuilder.hooks'),
56
59
    'bzrlib.version_info_formats.format_rio', 'RioVersionInfoBuilderHooks')
 
60
known_hooks.register_lazy(
 
61
    ('bzrlib.merge_directive', 'BaseMergeDirective.hooks'),
 
62
    'bzrlib.merge_directive', 'MergeDirectiveHooks')
57
63
 
58
64
 
59
65
def known_hooks_key_to_object((module_name, member_name)):
176
182
    :ivar introduced: A version tuple specifying what version the hook was
177
183
        introduced in. None indicates an unknown version.
178
184
    :ivar deprecated: A version tuple specifying what version the hook was
179
 
        deprecated or superceded in. None indicates that the hook is not
180
 
        superceded or deprecated. If the hook is superceded then the doc
 
185
        deprecated or superseded in. None indicates that the hook is not
 
186
        superseded or deprecated. If the hook is superseded then the doc
181
187
        should describe the recommended replacement hook to register for.
182
188
    :ivar doc: The docs for using the hook.
183
189
    """
214
220
        strings.append('Introduced in: %s' % introduced_string)
215
221
        if self.deprecated:
216
222
            deprecated_string = _format_version_tuple(self.deprecated)
217
 
        else:
218
 
            deprecated_string = 'Not deprecated'
219
 
        strings.append('Deprecated in: %s' % deprecated_string)
 
223
            strings.append('Deprecated in: %s' % deprecated_string)
220
224
        strings.append('')
221
 
        strings.extend(textwrap.wrap(self.__doc__))
 
225
        strings.extend(textwrap.wrap(self.__doc__,
 
226
            break_long_words=False))
222
227
        strings.append('')
223
228
        return '\n'.join(strings)
224
229
 
271
276
 
272
277
  yyy.hooks.install_named_hook("xxx", ...)
273
278
 
274
 
See `Using hooks`_ in the User Guide for examples.
275
 
 
276
 
.. _Using hooks: ../user-guide/index.html#using-hooks
 
279
See :doc:`Using hooks<../user-guide/hooks>` in the User Guide for examples.
277
280
 
278
281
The class that contains each hook is given before the hooks it supplies. For
279
282
instance, BranchHooks as the class is the hooks class for