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.
7 This will talk to an irkerd (currently assumed to be running on localhost)
10 Useful configuration settings:
11 irker_project - The name of the project used in announcements
12 irker_channels - The irc channels to post announcements to
13 irker_colours - Settings for using colours in the announcements (ANSI or
15 irker_server - Host for the irkerd server (localhost by default)
16 irker_port - port to connect to (6659 by default)
19 from bzrlib.config import option_registry
20 from bzrlib.lazy_import import lazy_import
22 # lazy_import so that it doesn't get loaded if it isn't used
23 # Approach borrowed from bzr-email
24 lazy_import(globals(), """\
25 from bzrlib.plugins.bzrirker import irkerhook as _irkerhook
29 def branch_commit_hook(local, master, old_revno, old_revid,
30 new_revno, new_revid):
31 """This is the post_commit hook that runs after commit."""
33 _irkerhook.IrkerSender(master, new_revid,
34 master.get_config_stack()).send()
36 _irkerhook.IrkerSender(local, new_revid,
37 master.get_config_stack()).send()
40 def branch_post_change_hook(params):
41 """This is the post_change_branch_tip hook."""
42 # (branch, old_revno, new_revno, old_revid, new_revid)
44 revs = br._revision_history()[params.old_revno:params.new_revno]
46 _irkerhook.IrkerSender(br, rev_id, br.get_config_stack()).send()
50 from unittest import TestSuite
51 import bzrlib.plugins.bzrirker.tests
53 result.addTest(bzrlib.plugins.bzrirker.tests.test_suite())
57 option_registry.register_lazy("irker_channels",
58 "bzrlib.plugins.bzrirker.irkerhook", "opt_irker_channels")
59 option_registry.register_lazy("irker_colours",
60 "bzrlib.plugins.bzrirker.irkerhook", "opt_irker_colours")
61 option_registry.register_lazy("irker_project",
62 "bzrlib.plugins.bzrirker.irkerhook", "opt_irker_project")
63 option_registry.register_lazy("irker_server",
64 "bzrlib.plugins.bzrirker.irkerhook", "opt_irker_server")
65 option_registry.register_lazy("irker_port",
66 "bzrlib.plugins.bzrirker.irkerhook", "opt_irker_port")
68 from bzrlib.hooks import install_lazy_named_hook
69 install_lazy_named_hook("bzrlib.branch", "Branch.hooks",
70 'post_commit', branch_post_change_hook, 'bzr-irker')