~vila/bzr/bzr-email

« back to all changes in this revision

Viewing changes to __init__.py

  • Committer: Robert Collins
  • Date: 2007-07-08 00:05:11 UTC
  • Revision ID: robertc@robertcollins.net-20070708000511-4inxppi8822gy1b1
DocumentationĀ overhaul.

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
 
"""Allow sending an email after a new commit.
18
 
 
19
 
This plugin provides a 'post_commit' hook, which is used to send an email (like
20
 
to a developer mailing list) with the basic contents of the change.
21
 
 
22
 
See the README file for basic information on how to configure this plugin.
 
17
"""Sending emails upon commit with informatiopn about the commit.
 
18
 
 
19
To have bzr send an email you need to configure an address to send mail
 
20
to for that branch. To do this set the configuration option ``post_commit_to``
 
21
and the address to send the mail from is read from the configuration option
 
22
``post_commit_sender`` (if not supplied defaults to the email address reported
 
23
by ``bzr whoami``).
 
24
 
 
25
By default, the diff for the commit will be included in the email, if the
 
26
length is less than 1000 lines. This limit can be changed (for instance, to 0
 
27
to disable the feature) by setting the configuration option
 
28
'post_commit_difflimit' to the number of lines you wish it to be limited to.
 
29
 
 
30
If you are using a bzr release from before 0.15, you need to manually tell
 
31
bzr about the commit action, by setting
 
32
post_commit=bzrlib.plugins.email.post_commit in bazaar.conf or locations.conf.
 
33
 
 
34
The URL of the branch is determined from the following checks (in order):
 
35
 - If the configuration value 'post_commit_url' is set, it is used.
 
36
 - If the configuration value 'public_branch' is set, it is used.
 
37
 - The URL of the branch itself.
 
38
 
 
39
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
 
41
http://).
 
42
 
 
43
How emails are sent is determined by the value of the configuration option
 
44
'post_commit_mailer':
 
45
 - Unset: use ``/usr/bin/mail``.
 
46
 - ``smtplib``: Use python's smtplib to send the mail. If you use 'smtplib' you
 
47
   can also configure the settings "smtp_server=host[:port]",
 
48
   "smtp_username=userid", "smtp_password". If "smtp_username" is set but
 
49
   "smtp_password" is not, you will be prompted for a password.S
 
50
 
 
51
   Also, if using 'smtplib', the messages will be sent as a UTF-8 text message,
 
52
   with a 8-bit text diff attached (rather than all-as-one). Work has also been
 
53
   done to make sure usernames do not have to be ascii.
 
54
 - Any other value: Run the value expecting it to behave like ``/usr/bin/mail``
 
55
   - in particular supporting the -s and -a options.
 
56
 
23
57
"""
24
58
 
25
59
 
29
63
                      % __name__)
30
64
 
31
65
 
 
66
# These three are used during import: No point lazy_importing them.
32
67
from bzrlib import errors
33
68
from bzrlib.branch import Branch
34
69
from bzrlib.lazy_import import lazy_import
40
75
 
41
76
 
42
77
def post_commit(branch, revision_id):
 
78
    """This is the post_commit hook that should get run after commit."""
43
79
    if not use_legacy:
44
80
        return
45
 
    """This is the post_commit hook that should get run after commit."""
46
81
    _emailer.EmailSender(branch, revision_id, branch.get_config()).send_maybe()
47
82
 
48
83