~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/hooks.py

  • Committer: Martin Pool
  • Date: 2010-09-09 00:32:58 UTC
  • mfrom: (5348.1.2 deprecation)
  • mto: This revision was merged to the branch mainline in revision 5415.
  • Revision ID: mbp@sourcefrog.net-20100909003258-ioyugglvmu32yvff
merge news

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
 
45
44
    'bzrlib.info', 'InfoHooks')
46
45
known_hooks.register_lazy(('bzrlib.lock', 'Lock.hooks'), 'bzrlib.lock',
47
46
    'LockHooks')
 
47
known_hooks.register_lazy(('bzrlib.merge', 'Merger.hooks'), 'bzrlib.merge',
 
48
    'MergeHooks')
48
49
known_hooks.register_lazy(('bzrlib.msgeditor', 'hooks'), 'bzrlib.msgeditor',
49
50
    'MessageEditorHooks')
50
51
known_hooks.register_lazy(('bzrlib.mutabletree', 'MutableTree.hooks'),
53
54
    'bzrlib.smart.client', 'SmartClientHooks')
54
55
known_hooks.register_lazy(('bzrlib.smart.server', 'SmartTCPServer.hooks'),
55
56
    'bzrlib.smart.server', 'SmartServerHooks')
 
57
known_hooks.register_lazy(('bzrlib.status', 'hooks'),
 
58
    'bzrlib.status', 'StatusHooks')
56
59
known_hooks.register_lazy(
57
60
    ('bzrlib.version_info_formats.format_rio', 'RioVersionInfoBuilder.hooks'),
58
61
    'bzrlib.version_info_formats.format_rio', 'RioVersionInfoBuilderHooks')
59
62
known_hooks.register_lazy(
60
 
    ('bzrlib.merge_directive', '_BaseMergeDirective.hooks'),
 
63
    ('bzrlib.merge_directive', 'BaseMergeDirective.hooks'),
61
64
    'bzrlib.merge_directive', 'MergeDirectiveHooks')
62
65
 
63
66
 
178
181
    """A single hook that clients can register to be called back when it fires.
179
182
 
180
183
    :ivar name: The name of the hook.
 
184
    :ivar doc: The docs for using the hook.
181
185
    :ivar introduced: A version tuple specifying what version the hook was
182
186
        introduced in. None indicates an unknown version.
183
187
    :ivar deprecated: A version tuple specifying what version the hook was
184
188
        deprecated or superseded in. None indicates that the hook is not
185
189
        superseded or deprecated. If the hook is superseded then the doc
186
190
        should describe the recommended replacement hook to register for.
187
 
    :ivar doc: The docs for using the hook.
188
191
    """
189
192
 
190
193
    def __init__(self, name, doc, introduced, deprecated):
219
222
        strings.append('Introduced in: %s' % introduced_string)
220
223
        if self.deprecated:
221
224
            deprecated_string = _format_version_tuple(self.deprecated)
222
 
        else:
223
 
            deprecated_string = 'Not deprecated'
224
 
        strings.append('Deprecated in: %s' % deprecated_string)
 
225
            strings.append('Deprecated in: %s' % deprecated_string)
225
226
        strings.append('')
226
227
        strings.extend(textwrap.wrap(self.__doc__,
227
228
            break_long_words=False))
277
278
 
278
279
  yyy.hooks.install_named_hook("xxx", ...)
279
280
 
280
 
See `Using hooks`_ in the User Guide for examples.
281
 
 
282
 
.. _Using hooks: ../user-guide/index.html#using-hooks
 
281
See :doc:`Using hooks<../user-guide/hooks>` in the User Guide for examples.
283
282
 
284
283
The class that contains each hook is given before the hooks it supplies. For
285
284
instance, BranchHooks as the class is the hooks class for