~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/hooks.py

  • Committer: Vincent Ladeuil
  • Date: 2009-04-06 14:01:16 UTC
  • mto: (4241.10.1 bzr.1.14)
  • mto: This revision was merged to the branch mainline in revision 4267.
  • Revision ID: v.ladeuil+lp@free.fr-20090406140116-zkbvjtaxfhbql4l4
Fix unicode related OSX failures.

* bzrlib/tests/test_export.py: 
Fix imports.

* bzrlib/tests/blackbox/test_export.py:
(TestExport.test_tar_export_unicode,
TestExport.test_zip_export_unicode): Use a less problematic
unicode char for OSX.

Show diffs side-by-side

added added

removed removed

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