/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/hooks.py

  • Committer: Martin Pool
  • Date: 2009-06-10 02:51:23 UTC
  • mfrom: (4423 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4464.
  • Revision ID: mbp@sourcefrog.net-20090610025123-2u0c0ng5jcezjzqh
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
 
18
18
"""Support for plugin hooking logic."""
 
19
from bzrlib import registry
19
20
from bzrlib.lazy_import import lazy_import
20
 
from bzrlib import registry
21
 
from bzrlib.symbol_versioning import deprecated_method, one_five
 
21
from bzrlib.symbol_versioning import deprecated_method
22
22
lazy_import(globals(), """
23
23
import textwrap
24
24
 
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.msgeditor', 'hooks'), 'bzrlib.msgeditor',
 
49
    'MessageEditorHooks')
42
50
known_hooks.register_lazy(('bzrlib.mutabletree', 'MutableTree.hooks'),
43
51
    'bzrlib.mutabletree', 'MutableTreeHooks')
44
52
known_hooks.register_lazy(('bzrlib.smart.client', '_SmartClient.hooks'),
45
53
    'bzrlib.smart.client', 'SmartClientHooks')
46
54
known_hooks.register_lazy(('bzrlib.smart.server', 'SmartTCPServer.hooks'),
47
55
    'bzrlib.smart.server', 'SmartServerHooks')
 
56
known_hooks.register_lazy(
 
57
    ('bzrlib.version_info_formats.format_rio', 'RioVersionInfoBuilder.hooks'),
 
58
    'bzrlib.version_info_formats.format_rio', 'RioVersionInfoBuilderHooks')
 
59
known_hooks.register_lazy(
 
60
    ('bzrlib.merge_directive', '_BaseMergeDirective.hooks'),
 
61
    'bzrlib.merge_directive', 'MergeDirectiveHooks')
48
62
 
49
63
 
50
64
def known_hooks_key_to_object((module_name, member_name)):
132
146
        """
133
147
        return self._callable_names.get(a_callable, "No hook name")
134
148
 
135
 
    @deprecated_method(one_five)
136
 
    def install_hook(self, hook_name, a_callable):
137
 
        """Install a_callable in to the hook hook_name.
138
 
 
139
 
        :param hook_name: A hook name. See the __init__ method of BranchHooks
140
 
            for the complete list of hooks.
141
 
        :param a_callable: The callable to be invoked when the hook triggers.
142
 
            The exact signature will depend on the hook - see the __init__
143
 
            method of BranchHooks for details on each hook.
144
 
        """
145
 
        self.install_named_hook(hook_name, a_callable, None)
146
 
 
147
149
    def install_named_hook(self, hook_name, a_callable, name):
148
150
        """Install a_callable in to the hook hook_name, and label it name.
149
151
 
179
181
    :ivar introduced: A version tuple specifying what version the hook was
180
182
        introduced in. None indicates an unknown version.
181
183
    :ivar deprecated: A version tuple specifying what version the hook was
182
 
        deprecated or superceded in. None indicates that the hook is not
183
 
        superceded or deprecated. If the hook is superceded then the doc
 
184
        deprecated or superseded in. None indicates that the hook is not
 
185
        superseded or deprecated. If the hook is superseded then the doc
184
186
        should describe the recommended replacement hook to register for.
185
187
    :ivar doc: The docs for using the hook.
186
188
    """