~bzr/bzr-email/ppa-daily

« back to all changes in this revision

Viewing changes to __init__.py

  • Committer: Jelmer Vernooij
  • Date: 2009-03-10 13:59:07 UTC
  • mfrom: (24.1.16 335332-starttls)
  • Revision ID: jelmer@debian.org-20090310135907-dztqd8qpdj4bl9af
New upstream snapshot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
 
"""Sending emails upon commit with information about the commit.
 
17
"""Sending emails for commits and branch changes.
18
18
 
19
19
To have bzr send an email you need to configure an address to send mail
20
20
to for that branch. To do this set the configuration option ``post_commit_to``
27
27
to disable the feature) by setting the configuration option
28
28
'post_commit_difflimit' to the number of lines you wish it to be limited to.
29
29
 
 
30
By default bzr-email only emails when a commit occurs, not when a push or
 
31
pull operation occurs. To email on push or pull set post_commit_push_pull=True
 
32
in the configuration.
 
33
 
30
34
If you are using a bzr release from before 0.15, you need to manually tell
31
35
bzr about the commit action, by setting
32
36
post_commit=bzrlib.plugins.email.post_commit in bazaar.conf or locations.conf.
37
41
 - The URL of the branch itself.
38
42
 
39
43
Setting public_branch is highly recommended if you commit via a protocol which
40
 
has a pricate address (e.g. bzr+ssh but anonymous access might be bzr:// or
 
44
has a private address (e.g. bzr+ssh but anonymous access might be bzr:// or
41
45
http://).
42
46
 
43
47
How emails are sent is determined by the value of the configuration option
46
50
 - ``smtplib``: Use python's smtplib to send the mail. If you use 'smtplib' you
47
51
   can also configure the settings "smtp_server=host[:port]",
48
52
   "smtp_username=userid", "smtp_password". If "smtp_username" is set but
49
 
   "smtp_password" is not, you will be prompted for a password.S
 
53
   "smtp_password" is not, you will be prompted for a password.
50
54
 
51
55
   Also, if using 'smtplib', the messages will be sent as a UTF-8 text message,
52
56
   with a 8-bit text diff attached (rather than all-as-one). Work has also been
87
91
                         local_branch=local).send_maybe()
88
92
 
89
93
 
 
94
def branch_post_change_hook(params):
 
95
    """This is the post_change_branch_tip hook."""
 
96
    # (branch, old_revno, new_revno, old_revid, new_revid)
 
97
    _emailer.EmailSender(params.branch, params.new_revid,
 
98
        params.branch.get_config(), local_branch=None, op='change').send_maybe()
 
99
 
 
100
 
90
101
def install_hooks():
91
102
    """Install CommitSender to send after commits with bzr >= 0.15 """
92
103
    install_named_hook = getattr(Branch.hooks, 'install_named_hook', None)
93
104
    if install_named_hook is not None:
94
105
        install_named_hook('post_commit', branch_commit_hook, 'bzr-email')
 
106
        if 'post_change_branch_tip' in Branch.hooks:
 
107
            install_named_hook('post_change_branch_tip',
 
108
                branch_post_change_hook, 'bzr-email')
95
109
    else:
96
110
        Branch.hooks.install_hook('post_commit', branch_commit_hook)
97
111
        if getattr(Branch.hooks, 'name_hook', None) is not None: