1 # -*- coding: utf-8 -*-
2 # vim:fileencoding=utf-8 ai ts=4 sts=4 et sw=4
3 # Copyright 2012 Neil Muller
4 # GPL 2+ - see COPYING for details
5 """Sending irker notifications for commits and branch changes.
10 from bzrlib.config import option_registry
11 from bzrlib.lazy_import import lazy_import
13 # lazy_import so that it doesn't get loaded if it isn't used
14 # Approach borrowed from bzr-email
15 lazy_import(globals(), """\
16 from bzrlib.plugins.irkerhook import irkerhook as _irkerhook
20 def post_commit(branch, revision_id):
21 """This is the post_commit hook that should get run after commit."""
22 _irkerhook.IrkerSender(branch, revision_id,
23 branch.get_config_stack()).send_maybe()
26 def branch_commit_hook(local, master, old_revno, old_revid,
27 new_revno, new_revid):
28 """This is the post_commit hook that runs after commit."""
29 _irkerhook.IrkerSender(master, new_revid, master.get_config_stack(),
30 local_branch=local).send_maybe()
33 def branch_post_change_hook(params):
34 """This is the post_change_branch_tip hook."""
35 # (branch, old_revno, new_revno, old_revid, new_revid)
36 _irker.IrkerSender(params.branch, params.new_revid,
37 params.branch.get_config_stack(), local_branch=None,
38 op='change').send_maybe()
42 from unittest import TestSuite
43 import bzrlib.plugins.irkerhook.tests
45 result.addTest(bzrlib.plugins.irkerhook.tests.test_suite())
49 option_registry.register_lazy("irker_channels",
50 "bzrlib.plugins.irkerhook.irkerhook", "opt_irker_channels")
51 option_registry.register_lazy("irker_colours",
52 "bzrlib.plugins.irkerhook.irkerhook", "opt_irker_colours")
53 option_registry.register_lazy("irker_url",
54 "bzrlib.plugins.irkerhook.irkerhook", "opt_irker_url")
56 from bzrlib.hooks import install_lazy_named_hook
57 install_lazy_named_hook("bzrlib.branch", "Branch.hooks", 'post_commit',
58 branch_commit_hook, 'bzr-irker')
59 install_lazy_named_hook("bzrlib.branch", "Branch.hooks",
60 'post_change_branch_tip', branch_post_change_hook, 'bzr-irker')