64
64
revision_mail_headers=X-Cheese: to the rescue!
68
if __name__ != 'bzrlib.plugins.email':
69
raise ImportError('The email plugin must be installed as'
70
' bzrlib.plugins.email not %s'
74
# These three are used during import: No point lazy_importing them.
75
from bzrlib import errors
76
from bzrlib.branch import Branch
67
from __future__ import absolute_import
69
from bzrlib.config import option_registry
77
70
from bzrlib.lazy_import import lazy_import
79
72
# lazy_import emailer so that it doesn't get loaded if it isn't used
85
78
def post_commit(branch, revision_id):
86
79
"""This is the post_commit hook that should get run after commit."""
87
_emailer.EmailSender(branch, revision_id, branch.get_config()).send_maybe()
80
_emailer.EmailSender(branch, revision_id, branch.get_config_stack()).send_maybe()
90
83
def branch_commit_hook(local, master, old_revno, old_revid, new_revno, new_revid):
91
84
"""This is the post_commit hook that runs after commit."""
92
_emailer.EmailSender(master, new_revid, master.get_config(),
85
_emailer.EmailSender(master, new_revid, master.get_config_stack(),
93
86
local_branch=local).send_maybe()
97
90
"""This is the post_change_branch_tip hook."""
98
91
# (branch, old_revno, new_revno, old_revid, new_revid)
99
92
_emailer.EmailSender(params.branch, params.new_revid,
100
params.branch.get_config(), local_branch=None, op='change').send_maybe()
93
params.branch.get_config_stack(), local_branch=None, op='change').send_maybe()
111
Branch.hooks.install_named_hook('post_commit', branch_commit_hook, 'bzr-email')
112
Branch.hooks.install_named_hook('post_change_branch_tip', branch_post_change_hook,
104
option_registry.register_lazy("post_commit_body",
105
"bzrlib.plugins.email.emailer", "opt_post_commit_body")
106
option_registry.register_lazy("post_commit_subject",
107
"bzrlib.plugins.email.emailer", "opt_post_commit_subject")
108
option_registry.register_lazy("post_commit_log_format",
109
"bzrlib.plugins.email.emailer", "opt_post_commit_log_format")
110
option_registry.register_lazy("post_commit_difflimit",
111
"bzrlib.plugins.email.emailer", "opt_post_commit_difflimit")
112
option_registry.register_lazy("post_commit_push_pull",
113
"bzrlib.plugins.email.emailer", "opt_post_commit_push_pull")
114
option_registry.register_lazy("post_commit_diffoptions",
115
"bzrlib.plugins.email.emailer", "opt_post_commit_diffoptions")
116
option_registry.register_lazy("post_commit_sender",
117
"bzrlib.plugins.email.emailer", "opt_post_commit_sender")
118
option_registry.register_lazy("post_commit_to",
119
"bzrlib.plugins.email.emailer", "opt_post_commit_to")
120
option_registry.register_lazy("post_commit_mailer",
121
"bzrlib.plugins.email.emailer", "opt_post_commit_mailer")
122
option_registry.register_lazy("revision_mail_headers",
123
"bzrlib.plugins.email.emailer", "opt_revision_mail_headers")
126
from bzrlib.hooks import install_lazy_named_hook
128
from bzrlib.branch import Branch
129
Branch.hooks.install_named_hook('post_commit', branch_commit_hook, 'bzr-email')
130
Branch.hooks.install_named_hook('post_change_branch_tip', branch_post_change_hook, 'bzr-email')
132
install_lazy_named_hook("bzrlib.branch", "Branch.hooks", 'post_commit',
133
branch_commit_hook, 'bzr-email')
134
install_lazy_named_hook("bzrlib.branch", "Branch.hooks",
135
'post_change_branch_tip', branch_post_change_hook, 'bzr-email')