Rev 19: Update email plugin to support bzr 0.15 branch hooks. in file:///home/robertc/source/baz/plugins/email/trunk/
Robert Collins
robertc at robertcollins.net
Tue Feb 6 02:46:45 GMT 2007
------------------------------------------------------------
revno: 19
revision-id: robertc at robertcollins.net-20070206024644-q5fn0kosfvfr78m0
parent: jelmer at samba.org-20070129132830-7fu6h9jba9vwk2iz
committer: Robert Collins <robertc at robertcollins.net>
branch nick: trunk
timestamp: Tue 2007-02-06 13:46:44 +1100
message:
Update email plugin to support bzr 0.15 branch hooks.
modified:
__init__.py __init__.py-20051018071212-f1765ec4521cab0b
=== modified file '__init__.py'
--- a/__init__.py 2007-01-29 13:28:30 +0000
+++ b/__init__.py 2007-02-06 02:46:44 +0000
@@ -18,6 +18,7 @@
from StringIO import StringIO
import subprocess
+from bzrlib.branch import Branch
import bzrlib.config as config
import bzrlib.errors as errors
@@ -167,9 +168,20 @@
def post_commit(branch, revision_id):
+ if not use_legacy:
+ return
EmailSender(branch, revision_id, config.BranchConfig(branch)).send_maybe()
+def branch_commit_hook(local, master, old_revno, old_revid, new_revno, new_revid):
+ EmailSender(master, new_revid, config.BranchConfig(master)).send_maybe()
+
+
+def install_hooks():
+ """Install CommitSender to send after commits with bzr >= 0.15 """
+ Branch.hooks.install_hook('post_commit', branch_commit_hook)
+
+
def test_suite():
from unittest import TestSuite
import bzrlib.plugins.email.tests
@@ -177,3 +189,14 @@
result.addTest(bzrlib.plugins.email.tests.test_suite())
return result
+
+# setup the email plugin with > 0.15 hooks.
+try:
+ install_hooks()
+ use_legacy = False
+except AttributeError:
+ # bzr < 0.15 - no Branch.hooks
+ use_legacy = True
+except errors.UnknownHook:
+ # bzr 0.15 dev before post_commit was added
+ use_legacy = True
More information about the bazaar-commits
mailing list