bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
0.175.3
by John Arbash Meinel
Move guts into another file to improve startup time, fix bug when old revid is None. |
1 |
# Copyright (C) 2005, 2006, 2007 Canonical Ltd
|
|
0.171.1
by Robert Collins
Start working toward publish - get a publishing_root option |
2 |
#
|
3 |
# This program is free software; you can redistribute it and/or modify
|
|
4 |
# it under the terms of the GNU General Public License as published by
|
|
5 |
# the Free Software Foundation; either version 2 of the License, or
|
|
6 |
# (at your option) any later version.
|
|
7 |
#
|
|
8 |
# This program is distributed in the hope that it will be useful,
|
|
9 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
10 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
11 |
# GNU General Public License for more details.
|
|
12 |
#
|
|
13 |
# You should have received a copy of the GNU General Public License
|
|
14 |
# along with this program; if not, write to the Free Software
|
|
15 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
16 |
||
|
0.171.39
by Robert Collins
Draft support for mailing on push/pull. |
17 |
"""Sending emails for commits and branch changes.
|
|
0.171.27
by Robert Collins
Documentation overhaul. |
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 |
||
|
0.171.39
by Robert Collins
Draft support for mailing on push/pull. |
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 |
||
|
0.171.27
by Robert Collins
Documentation overhaul. |
34 |
If you are using a bzr release from before 0.15, you need to manually tell
|
35 |
bzr about the commit action, by setting
|
|
36 |
post_commit=bzrlib.plugins.email.post_commit in bazaar.conf or locations.conf.
|
|
37 |
||
38 |
The URL of the branch is determined from the following checks (in order):
|
|
39 |
- If the configuration value 'post_commit_url' is set, it is used.
|
|
40 |
- If the configuration value 'public_branch' is set, it is used.
|
|
41 |
- The URL of the branch itself.
|
|
42 |
||
43 |
Setting public_branch is highly recommended if you commit via a protocol which
|
|
|
0.171.35
by Jelmer Vernooij
Fix typo: pricate -> private. |
44 |
has a private address (e.g. bzr+ssh but anonymous access might be bzr:// or
|
|
0.171.27
by Robert Collins
Documentation overhaul. |
45 |
http://).
|
46 |
||
47 |
How emails are sent is determined by the value of the configuration option
|
|
48 |
'post_commit_mailer':
|
|
49 |
- Unset: use ``/usr/bin/mail``.
|
|
50 |
- ``smtplib``: Use python's smtplib to send the mail. If you use 'smtplib' you
|
|
51 |
can also configure the settings "smtp_server=host[:port]",
|
|
52 |
"smtp_username=userid", "smtp_password". If "smtp_username" is set but
|
|
|
0.171.36
by Jelmer Vernooij
Fix another typo pointed out by Elmo. |
53 |
"smtp_password" is not, you will be prompted for a password.
|
|
0.171.27
by Robert Collins
Documentation overhaul. |
54 |
|
55 |
Also, if using 'smtplib', the messages will be sent as a UTF-8 text message,
|
|
56 |
with a 8-bit text diff attached (rather than all-as-one). Work has also been
|
|
57 |
done to make sure usernames do not have to be ascii.
|
|
58 |
- Any other value: Run the value expecting it to behave like ``/usr/bin/mail``
|
|
59 |
- in particular supporting the -s and -a options.
|
|
60 |
||
|
0.175.3
by John Arbash Meinel
Move guts into another file to improve startup time, fix bug when old revid is None. |
61 |
"""
|
|
0.171.4
by Robert Collins
basics are all there |
62 |
|
|
0.171.3
by Robert Collins
convert the switch basics to an email plugin |
63 |
|
|
0.171.22
by John Arbash Meinel
Cleanup import logic, and use lazy importing |
64 |
if __name__ != 'bzrlib.plugins.email': |
65 |
raise ImportError('The email plugin must be installed as' |
|
66 |
' bzrlib.plugins.email not %s' |
|
67 |
% __name__) |
|
68 |
||
69 |
||
|
0.171.27
by Robert Collins
Documentation overhaul. |
70 |
# These three are used during import: No point lazy_importing them.
|
|
0.171.21
by Robert Collins
Merge up with HEAD. |
71 |
from bzrlib import errors |
|
0.171.19
by Robert Collins
Update email plugin to support bzr 0.15 branch hooks. |
72 |
from bzrlib.branch import Branch |
|
0.171.22
by John Arbash Meinel
Cleanup import logic, and use lazy importing |
73 |
from bzrlib.lazy_import import lazy_import |
74 |
||
75 |
# lazy_import emailer so that it doesn't get loaded if it isn't used
|
|
76 |
lazy_import(globals(), """\ |
|
|
0.171.23
by John Arbash Meinel
Can't have a lazy imported object with the identical name as the actual module. |
77 |
from bzrlib.plugins.email import emailer as _emailer
|
|
0.171.22
by John Arbash Meinel
Cleanup import logic, and use lazy importing |
78 |
""") |
|
0.171.4
by Robert Collins
basics are all there |
79 |
|
|
0.171.3
by Robert Collins
convert the switch basics to an email plugin |
80 |
|
81 |
def post_commit(branch, revision_id): |
|
|
0.171.27
by Robert Collins
Documentation overhaul. |
82 |
"""This is the post_commit hook that should get run after commit.""" |
|
0.171.19
by Robert Collins
Update email plugin to support bzr 0.15 branch hooks. |
83 |
if not use_legacy: |
84 |
return
|
|
|
0.171.23
by John Arbash Meinel
Can't have a lazy imported object with the identical name as the actual module. |
85 |
_emailer.EmailSender(branch, revision_id, branch.get_config()).send_maybe() |
|
0.171.3
by Robert Collins
convert the switch basics to an email plugin |
86 |
|
87 |
||
|
0.171.19
by Robert Collins
Update email plugin to support bzr 0.15 branch hooks. |
88 |
def branch_commit_hook(local, master, old_revno, old_revid, new_revno, new_revid): |
|
0.171.21
by Robert Collins
Merge up with HEAD. |
89 |
"""This is the post_commit hook that runs after commit.""" |
|
0.171.24
by John Arbash Meinel
Switch to using a local repository if available, |
90 |
_emailer.EmailSender(master, new_revid, master.get_config(), |
91 |
local_branch=local).send_maybe() |
|
|
0.171.19
by Robert Collins
Update email plugin to support bzr 0.15 branch hooks. |
92 |
|
93 |
||
|
0.171.39
by Robert Collins
Draft support for mailing on push/pull. |
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 |
||
|
0.171.19
by Robert Collins
Update email plugin to support bzr 0.15 branch hooks. |
101 |
def install_hooks(): |
102 |
"""Install CommitSender to send after commits with bzr >= 0.15 """ |
|
|
0.171.32
by John Arbash Meinel
Use install_named_hook if it is available |
103 |
install_named_hook = getattr(Branch.hooks, 'install_named_hook', None) |
|
0.171.33
by John Arbash Meinel
Switch to using 'is not None' |
104 |
if install_named_hook is not None: |
|
0.171.32
by John Arbash Meinel
Use install_named_hook if it is available |
105 |
install_named_hook('post_commit', branch_commit_hook, 'bzr-email') |
|
0.171.39
by Robert Collins
Draft support for mailing on push/pull. |
106 |
if 'post_change_branch_tip' in Branch.hooks: |
107 |
install_named_hook('post_change_branch_tip', |
|
108 |
branch_post_change_hook, 'bzr-email') |
|
|
0.171.32
by John Arbash Meinel
Use install_named_hook if it is available |
109 |
else: |
110 |
Branch.hooks.install_hook('post_commit', branch_commit_hook) |
|
|
0.171.33
by John Arbash Meinel
Switch to using 'is not None' |
111 |
if getattr(Branch.hooks, 'name_hook', None) is not None: |
|
0.171.32
by John Arbash Meinel
Use install_named_hook if it is available |
112 |
Branch.hooks.name_hook(branch_commit_hook, "bzr-email") |
|
0.171.19
by Robert Collins
Update email plugin to support bzr 0.15 branch hooks. |
113 |
|
114 |
||
|
0.171.1
by Robert Collins
Start working toward publish - get a publishing_root option |
115 |
def test_suite(): |
116 |
from unittest import TestSuite |
|
|
0.171.22
by John Arbash Meinel
Cleanup import logic, and use lazy importing |
117 |
import bzrlib.plugins.email.tests |
|
0.171.1
by Robert Collins
Start working toward publish - get a publishing_root option |
118 |
result = TestSuite() |
|
0.171.3
by Robert Collins
convert the switch basics to an email plugin |
119 |
result.addTest(bzrlib.plugins.email.tests.test_suite()) |
|
0.171.1
by Robert Collins
Start working toward publish - get a publishing_root option |
120 |
return result |
121 |
||
|
0.171.19
by Robert Collins
Update email plugin to support bzr 0.15 branch hooks. |
122 |
|
123 |
# setup the email plugin with > 0.15 hooks.
|
|
124 |
try: |
|
125 |
install_hooks() |
|
126 |
use_legacy = False |
|
127 |
except AttributeError: |
|
128 |
# bzr < 0.15 - no Branch.hooks
|
|
129 |
use_legacy = True |
|
130 |
except errors.UnknownHook: |
|
131 |
# bzr 0.15 dev before post_commit was added
|
|
132 |
use_legacy = True |