~ubuntu-branches/debian/sid/bzr-email/sid

« back to all changes in this revision

Viewing changes to __init__.py

  • Committer: Package Import Robot
  • Author(s): Jelmer Vernooij
  • Date: 2012-03-29 16:34:55 UTC
  • mfrom: (1.1.7)
  • Revision ID: package-import@ubuntu.com-20120329163455-c20u75w3vullbncd
Tags: 0.0.1~bzr57-1
* Refer to specific GPL version file.
* New upstream snapshot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
64
64
  revision_mail_headers=X-Cheese: to the rescue!
65
65
"""
66
66
 
67
 
 
68
 
if __name__ != 'bzrlib.plugins.email':
69
 
    raise ImportError('The email plugin must be installed as'
70
 
                      ' bzrlib.plugins.email not %s'
71
 
                      % __name__)
72
 
 
73
 
 
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
 
68
 
 
69
from bzrlib.config import option_registry
77
70
from bzrlib.lazy_import import lazy_import
78
71
 
79
72
# lazy_import emailer so that it doesn't get loaded if it isn't used
84
77
 
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()
88
81
 
89
82
 
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()
94
87
 
95
88
 
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()
101
94
 
102
95
 
103
96
def test_suite():
108
101
    return result
109
102
 
110
103
 
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,
113
 
    'bzr-email')
 
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")
 
124
 
 
125
try:
 
126
    from bzrlib.hooks import install_lazy_named_hook
 
127
except ImportError:
 
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')
 
131
else:
 
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')