X-Git-Url: https://git.ctpug.org.za/?a=blobdiff_plain;f=__init__.py;h=26d45a2cd80aeb200bf7c8fd2bfbb04bff9da88d;hb=8cd1b16a02c99132d2383ade0b3d7da43fe73054;hp=31a26806f81ca9ab2087b1bfcfde5039105ac581;hpb=044cea8437cfe55bee35cc06318c06d7bc6a70fa;p=bzrirker.git diff --git a/__init__.py b/__init__.py index 31a2680..26d45a2 100644 --- a/__init__.py +++ b/__init__.py @@ -13,48 +13,49 @@ from bzrlib.lazy_import import lazy_import # lazy_import so that it doesn't get loaded if it isn't used # Approach borrowed from bzr-email lazy_import(globals(), """\ -from bzrlib.plugins.irkerhook import irkerhook as _irkerhook +from bzrlib.plugins.bzrirker import irkerhook as _irkerhook """) -def post_commit(branch, revision_id): - """This is the post_commit hook that should get run after commit.""" - _irkerhook.IrkerSender(branch, revision_id, - branch.get_config_stack()).send_maybe() - def branch_commit_hook(local, master, old_revno, old_revid, new_revno, new_revid): """This is the post_commit hook that runs after commit.""" - _irkerhook.IrkerSender(master, new_revid, master.get_config_stack(), - local_branch=local).send_maybe() + if local is None: + _irkerhook.IrkerSender(master, new_revid, + master.get_config_stack()).send() + else: + _irkerhook.IrkerSender(local, new_revid, + master.get_config_stack()).send() def branch_post_change_hook(params): """This is the post_change_branch_tip hook.""" # (branch, old_revno, new_revno, old_revid, new_revid) - _irker.IrkerSender(params.branch, params.new_revid, - params.branch.get_config_stack(), local_branch=None, - op='change').send_maybe() + br = params.branch + revs = br._revision_history()[params.old_revno:params.new_revno] + for rev_id in revs: + _irkerhook.IrkerSender(br, rev_id, br.get_config_stack()).send() def test_suite(): from unittest import TestSuite - import bzrlib.plugins.irkerhook.tests + import bzrlib.plugins.bzrirker.tests result = TestSuite() - result.addTest(bzrlib.plugins.irkerhook.tests.test_suite()) + result.addTest(bzrlib.plugins.bzrirker.tests.test_suite()) return result option_registry.register_lazy("irker_channels", - "bzrlib.plugins.irkerhook.irkerhook", "opt_irker_channels") + "bzrlib.plugins.bzrirker.irkerhook", "opt_irker_channels") option_registry.register_lazy("irker_colours", - "bzrlib.plugins.irkerhook.irkerhook", "opt_irker_colours") -option_registry.register_lazy("irker_url", - "bzrlib.plugins.irkerhook.irkerhook", "opt_irker_url") + "bzrlib.plugins.bzrirker.irkerhook", "opt_irker_colours") +option_registry.register_lazy("irker_project", + "bzrlib.plugins.bzrirker.irkerhook", "opt_irker_project") from bzrlib.hooks import install_lazy_named_hook -install_lazy_named_hook("bzrlib.branch", "Branch.hooks", 'post_commit', - branch_commit_hook, 'bzr-irker') +# This causes double commit messages - investigate what we need further +#install_lazy_named_hook("bzrlib.branch", "Branch.hooks", 'post_commit', +# branch_commit_hook, 'bzr-irker') install_lazy_named_hook("bzrlib.branch", "Branch.hooks", 'post_change_branch_tip', branch_post_change_hook, 'bzr-irker')