~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/hooks.py

  • Committer: Vincent Ladeuil
  • Date: 2010-04-23 08:51:52 UTC
  • mfrom: (5131.2.6 support_OO_flag)
  • mto: This revision was merged to the branch mainline in revision 5179.
  • Revision ID: v.ladeuil+lp@free.fr-20100423085152-uoewc1vnkwqhw0pj
Manually assign docstrings to command objects, so that they work with python -OO

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
31
31
 
32
32
 
33
33
known_hooks = registry.Registry()
 
34
# known_hooks registry contains
 
35
# tuple of (module, member name) which is the hook point
 
36
# module where the specific hooks are defined
 
37
# callable to get the empty specific Hooks for that attribute
34
38
known_hooks.register_lazy(('bzrlib.branch', 'Branch.hooks'), 'bzrlib.branch',
35
39
    'BranchHooks')
36
40
known_hooks.register_lazy(('bzrlib.bzrdir', 'BzrDir.hooks'), 'bzrlib.bzrdir',
37
41
    'BzrDirHooks')
38
42
known_hooks.register_lazy(('bzrlib.commands', 'Command.hooks'),
39
43
    'bzrlib.commands', 'CommandHooks')
 
44
known_hooks.register_lazy(('bzrlib.info', 'hooks'),
 
45
    'bzrlib.info', 'InfoHooks')
40
46
known_hooks.register_lazy(('bzrlib.lock', 'Lock.hooks'), 'bzrlib.lock',
41
47
    'LockHooks')
 
48
known_hooks.register_lazy(('bzrlib.merge', 'Merger.hooks'), 'bzrlib.merge',
 
49
    'MergeHooks')
 
50
known_hooks.register_lazy(('bzrlib.msgeditor', 'hooks'), 'bzrlib.msgeditor',
 
51
    'MessageEditorHooks')
42
52
known_hooks.register_lazy(('bzrlib.mutabletree', 'MutableTree.hooks'),
43
53
    'bzrlib.mutabletree', 'MutableTreeHooks')
44
54
known_hooks.register_lazy(('bzrlib.smart.client', '_SmartClient.hooks'),
45
55
    'bzrlib.smart.client', 'SmartClientHooks')
46
56
known_hooks.register_lazy(('bzrlib.smart.server', 'SmartTCPServer.hooks'),
47
57
    'bzrlib.smart.server', 'SmartServerHooks')
 
58
known_hooks.register_lazy(
 
59
    ('bzrlib.version_info_formats.format_rio', 'RioVersionInfoBuilder.hooks'),
 
60
    'bzrlib.version_info_formats.format_rio', 'RioVersionInfoBuilderHooks')
 
61
known_hooks.register_lazy(
 
62
    ('bzrlib.merge_directive', 'BaseMergeDirective.hooks'),
 
63
    'bzrlib.merge_directive', 'MergeDirectiveHooks')
48
64
 
49
65
 
50
66
def known_hooks_key_to_object((module_name, member_name)):
167
183
    :ivar introduced: A version tuple specifying what version the hook was
168
184
        introduced in. None indicates an unknown version.
169
185
    :ivar deprecated: A version tuple specifying what version the hook was
170
 
        deprecated or superceded in. None indicates that the hook is not
171
 
        superceded or deprecated. If the hook is superceded then the doc
 
186
        deprecated or superseded in. None indicates that the hook is not
 
187
        superseded or deprecated. If the hook is superseded then the doc
172
188
        should describe the recommended replacement hook to register for.
173
189
    :ivar doc: The docs for using the hook.
174
190
    """
205
221
        strings.append('Introduced in: %s' % introduced_string)
206
222
        if self.deprecated:
207
223
            deprecated_string = _format_version_tuple(self.deprecated)
208
 
        else:
209
 
            deprecated_string = 'Not deprecated'
210
 
        strings.append('Deprecated in: %s' % deprecated_string)
 
224
            strings.append('Deprecated in: %s' % deprecated_string)
211
225
        strings.append('')
212
 
        strings.extend(textwrap.wrap(self.__doc__))
 
226
        strings.extend(textwrap.wrap(self.__doc__,
 
227
            break_long_words=False))
213
228
        strings.append('')
214
229
        return '\n'.join(strings)
215
230
 
264
279
 
265
280
See `Using hooks`_ in the User Guide for examples.
266
281
 
267
 
.. _Using hooks: ../user-guide/index.html#using-hooks
 
282
.. _Using hooks: ../user-guide/hooks.html
268
283
 
269
284
The class that contains each hook is given before the hooks it supplies. For
270
285
instance, BranchHooks as the class is the hooks class for