[Pkg-bazaar-commits] ./bzr-email/unstable r43: Package new snapshot.
Jelmer Vernooij
jelmer at samba.org
Thu May 15 15:46:12 UTC 2008
------------------------------------------------------------
revno: 43
committer: Jelmer Vernooij <jelmer at samba.org>
branch nick: debian
timestamp: Thu 2008-05-15 17:46:12 +0200
message:
Package new snapshot.
modified:
README
__init__.py
debian/changelog
emailer.py
smtp_connection.py
------------------------------------------------------------
revno: 24.1.2
committer: Robert Collins <robertc at robertcollins.net>
branch nick: trunk
timestamp: Thu 2007-06-28 17:13:47 +1000
message:
Name the email plugin for 0.18.
modified:
__init__.py
------------------------------------------------------------
revno: 24.1.3
committer: Robert Collins <robertc at robertcollins.net>
branch nick: trunk
timestamp: Sun 2007-07-08 10:05:11 +1000
message:
Documentation overhaul.
modified:
README
__init__.py
------------------------------------------------------------
revno: 24.1.4
committer: Robert Collins <robertc at robertcollins.net>
branch nick: trunk
timestamp: Sun 2007-07-08 16:57:27 +1000
message:
Fix typo.
modified:
__init__.py
------------------------------------------------------------
revno: 24.1.5
committer: Robert Collins <robertc at robertcollins.net>
branch nick: trunk
timestamp: Thu 2007-09-20 07:38:05 +1000
message:
Empty strings should not count as email addresses for should_send.
modified:
emailer.py
------------------------------------------------------------
revno: 24.1.6
committer: Robert Collins <robertc at robertcollins.net>
branch nick: trunk
timestamp: Thu 2007-11-15 05:04:45 +1100
message:
Provide a feedback/contact address.
modified:
README
------------------------------------------------------------
revno: 24.1.7
author: Scott Wilson <scott-idealist at launchpad.net>
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: email
timestamp: Tue 2008-04-29 09:02:52 -0500
message:
Raise the right errors when smtp connection, etc fails. (bug #224202)
We were raising a raw BzrCommandError, but had only imported 'from bzrlib import errors'
modified:
smtp_connection.py
------------------------------------------------------------
revno: 24.1.8
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: email
timestamp: Thu 2008-05-01 15:01:21 -0500
message:
Use install_named_hook if it is available
modified:
__init__.py
------------------------------------------------------------
revno: 24.1.9
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: email
timestamp: Thu 2008-05-01 17:59:50 -0500
message:
Switch to using 'is not None'
modified:
__init__.py
-------------- next part --------------
=== modified file 'README'
--- a/README 2007-02-07 00:11:04 +0000
+++ b/README 2007-11-14 18:04:45 +0000
@@ -1,36 +1,30 @@
-This is a plugin to implement post commmit emails for bzr.
-This should eventually allow format specifiers.
-
-The plugin is activated by installing it (check it out to
-~/.bazaar/plugins/email - 'ls ~/.bazaar/plugins/email/__init__.py' should list
-a file), and then configure an address to send to as listed below.
-
-NB: If you are using a bzr release from before 0.15, you need to manually tell
-bzr about the commit action, by setting
-post_commit=bzrlib.plugins.email.post_commit in bazaar.conf or locations.conf.
-
-The address to sent to is read from 'post_commit_to' and the address to send
-from from 'post_commit_sender' (if not supplied defaults to standard bzr
-'email').
-
-If 'post_commit_url' is set, it is used instead of the branch URL
-(useful since in most cases, you commit to a private url, and you want
-the public HTTP url in the commit message).
-
-The option 'post_commit_mailer' can be used to override the name of
-the mail program to use. It should behave like /bin/mail, at minimum
-supporting the -s and -a options.
-
-Alternatively 'post_commit_mailer' can be set to 'smtplib' which will use
-python's smtplib to send the email directly. If you use 'smtplib' you can also
-configure the settings "smtp_server=host[:port]", "smtp_username=userid",
-"smtp_password". If "smtp_username" is set but "smtp_password" is not, you
-will be prompted for a password.
-Also, if using 'smtplib', the messages will be sent as a UTF-8 text message,
-with a 8-bit text diff attached (rather than all-as-one). Work has also been
-done to make sure usernames do not have to be ascii.
-
-By default, the diff for the commit will be included in the email, if the
-length is less than 1000 lines. This limit can be changed (for instance, to 0
-to disable the feature) by setting the option 'post_commit_difflimit' to the
-number of lines you wish it to be limited to.
+This is a plugin which implements post commmit emails for bzr.
+
+The plugin is activated by:
+ - installing it
+ - configuring an address to send emails to (see ``bzr help email``).
+
+Installation
+------------
+
+The simplest way to install it for a single user is to do
+``bzr checkout https://launchpad.net/bzr-email ~/.bazaar/plugins/email``.
+
+If you need to install it system wide, or are packing the plugin for non-source
+distribution (e.g. as a .deb or .rpm) then there is a setup.py file that should
+do the right thing when called with the values you use elsewhere when
+installing python softare.
+
+After installing it you can use 'bzr help email' for documentation (for bzr >=
+0.16), or read the docstring at the top of __init__.py (for bzr < 0.16)
+
+TODO
+----
+
+ - support format specifiers / email templates.
+
+Feedback/Contributions
+----------------------
+
+Feedback and contributions should be sent to the Bazaar mailing list:
+bazaar at lists.canonical.com.
=== modified file '__init__.py'
--- a/__init__.py 2007-02-17 18:09:12 +0000
+++ b/__init__.py 2008-05-01 22:59:50 +0000
@@ -14,12 +14,46 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-"""Allow sending an email after a new commit.
-
-This plugin provides a 'post_commit' hook, which is used to send an email (like
-to a developer mailing list) with the basic contents of the change.
-
-See the README file for basic information on how to configure this plugin.
+"""Sending emails upon commit with information about the commit.
+
+To have bzr send an email you need to configure an address to send mail
+to for that branch. To do this set the configuration option ``post_commit_to``
+and the address to send the mail from is read from the configuration option
+``post_commit_sender`` (if not supplied defaults to the email address reported
+by ``bzr whoami``).
+
+By default, the diff for the commit will be included in the email, if the
+length is less than 1000 lines. This limit can be changed (for instance, to 0
+to disable the feature) by setting the configuration option
+'post_commit_difflimit' to the number of lines you wish it to be limited to.
+
+If you are using a bzr release from before 0.15, you need to manually tell
+bzr about the commit action, by setting
+post_commit=bzrlib.plugins.email.post_commit in bazaar.conf or locations.conf.
+
+The URL of the branch is determined from the following checks (in order):
+ - If the configuration value 'post_commit_url' is set, it is used.
+ - If the configuration value 'public_branch' is set, it is used.
+ - The URL of the branch itself.
+
+Setting public_branch is highly recommended if you commit via a protocol which
+has a pricate address (e.g. bzr+ssh but anonymous access might be bzr:// or
+http://).
+
+How emails are sent is determined by the value of the configuration option
+'post_commit_mailer':
+ - Unset: use ``/usr/bin/mail``.
+ - ``smtplib``: Use python's smtplib to send the mail. If you use 'smtplib' you
+ can also configure the settings "smtp_server=host[:port]",
+ "smtp_username=userid", "smtp_password". If "smtp_username" is set but
+ "smtp_password" is not, you will be prompted for a password.S
+
+ Also, if using 'smtplib', the messages will be sent as a UTF-8 text message,
+ with a 8-bit text diff attached (rather than all-as-one). Work has also been
+ done to make sure usernames do not have to be ascii.
+ - Any other value: Run the value expecting it to behave like ``/usr/bin/mail``
+ - in particular supporting the -s and -a options.
+
"""
@@ -29,6 +63,7 @@
% __name__)
+# These three are used during import: No point lazy_importing them.
from bzrlib import errors
from bzrlib.branch import Branch
from bzrlib.lazy_import import lazy_import
@@ -40,9 +75,9 @@
def post_commit(branch, revision_id):
+ """This is the post_commit hook that should get run after commit."""
if not use_legacy:
return
- """This is the post_commit hook that should get run after commit."""
_emailer.EmailSender(branch, revision_id, branch.get_config()).send_maybe()
@@ -54,7 +89,13 @@
def install_hooks():
"""Install CommitSender to send after commits with bzr >= 0.15 """
- Branch.hooks.install_hook('post_commit', branch_commit_hook)
+ install_named_hook = getattr(Branch.hooks, 'install_named_hook', None)
+ if install_named_hook is not None:
+ install_named_hook('post_commit', branch_commit_hook, 'bzr-email')
+ else:
+ Branch.hooks.install_hook('post_commit', branch_commit_hook)
+ if getattr(Branch.hooks, 'name_hook', None) is not None:
+ Branch.hooks.name_hook(branch_commit_hook, "bzr-email")
def test_suite():
=== modified file 'debian/changelog'
--- a/debian/changelog 2007-12-06 14:47:48 +0000
+++ b/debian/changelog 2008-05-15 15:46:12 +0000
@@ -1,3 +1,9 @@
+bzr-email (0.0.1~bzr33-1) unstable; urgency=low
+
+ * New upstream snapshot.
+
+ -- Jelmer Vernooij <jelmer at samba.org> Thu, 15 May 2008 17:45:13 +0200
+
bzr-email (0.0.1~bzr30-1) unstable; urgency=low
* Mark as enhancing bzr.
=== modified file 'emailer.py'
--- a/emailer.py 2007-02-17 18:09:12 +0000
+++ b/emailer.py 2007-09-19 21:38:05 +0000
@@ -222,7 +222,7 @@
self.diff_filename())
def should_send(self):
- return self.to() is not None and self.from_address() is not None
+ return self.to() and self.from_address()
def send_maybe(self):
if self.should_send():
=== modified file 'smtp_connection.py'
--- a/smtp_connection.py 2007-01-26 15:23:32 +0000
+++ b/smtp_connection.py 2008-04-29 14:02:52 +0000
@@ -28,9 +28,11 @@
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart
from email.utils import parseaddr
+import socket
import smtplib
from bzrlib import (
+ errors,
ui,
__version__ as _bzrlib_version,
)
@@ -67,7 +69,13 @@
def _create_connection(self):
"""Create an SMTP connection."""
self._connection = smtplib.SMTP()
- self._connection.connect(self._smtp_server)
+ try:
+ self._connection.connect(self._smtp_server)
+ except socket.error, e:
+ raise errors.SocketConnectionError(
+ host=self._smtp_server,
+ msg="Unable to connect to smtp server to send email to",
+ orig_error=e)
# If this fails, it just returns an error, but it shouldn't raise an
# exception unless something goes really wrong (in which case we want
@@ -87,13 +95,13 @@
try:
self._connection.login(self._smtp_username, self._smtp_password)
except smtplib.SMTPHeloError, e:
- raise BzrCommandError('SMTP server refused HELO: %d %s'
- % (e.smtp_code, e.smtp_error))
+ raise errors.BzrCommandError('SMTP server refused HELO: %d %s'
+ % (e.smtp_code, e.smtp_error))
except smtplib.SMTPAuthenticationError, e:
- raise BzrCommandError('SMTP server refused authentication: %d %s'
- % (e.smtp_code, e.smtp_error))
+ raise errors.BzrCommandError('SMTP server refused authentication: %d %s'
+ % (e.smtp_code, e.smtp_error))
except smtplib.SMTPException, e:
- raise BzrCommandError(str(e))
+ raise errors.BzrCommandError(str(e))
@staticmethod
def _split_address(address):
More information about the Pkg-bazaar-commits
mailing list