[Pkg-bazaar-commits] ./bzr-email/unstable r49: New upstream snapshot.

Jelmer Vernooij jelmer at debian.org
Fri Apr 10 07:14:31 UTC 2009


------------------------------------------------------------
revno: 49
committer: Jelmer Vernooij <jelmer at debian.org>
branch nick: unstable
timestamp: Tue 2009-03-10 14:59:07 +0100
message:
  New upstream snapshot.
modified:
  __init__.py
  debian/changelog
  debian/compat
  debian/control
  emailer.py
  smtp_connection.py
  tests/testemail.py
    ------------------------------------------------------------
    revno: 24.1.11
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: trunk
    timestamp: Tue 2008-08-05 23:12:27 +0200
    message:
      Fix typo: pricate -> private.
    modified:
      __init__.py
    ------------------------------------------------------------
    revno: 24.1.12
    committer: Jelmer Vernooij <jelmer at samba.org>
    branch nick: trunk
    timestamp: Tue 2008-08-05 23:51:27 +0200
    message:
      Fix another typo pointed out by Elmo.
    modified:
      __init__.py
    ------------------------------------------------------------
    revno: 24.1.13
    committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
    branch nick: email
    timestamp: Thu 2008-09-25 12:19:27 +0200
    message:
      Long forgotten, approved, local patch fixing test suite failures
    modified:
      emailer.py
        ------------------------------------------------------------
        revno: 24.2.1
        committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
        branch nick: email
        timestamp: Wed 2008-05-21 09:27:48 +0200
        message:
          should_send does not always return a boolean anymore.
          
          * testemail.py:
          Make the test suite pass again.
        modified:
          tests/testemail.py
        ------------------------------------------------------------
        revno: 24.2.2
        committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
        branch nick: email
        timestamp: Wed 2008-05-21 10:39:45 +0200
        message:
          Fixed as per Robert's review.
          
          * tests/testemail.py:
          (TestGetTo.test_should_send): Revert previous changes.
          
          * emailer.py:
          (EmailSender.should_send): Return a boolean.
        modified:
          emailer.py
          tests/testemail.py
    ------------------------------------------------------------
    revno: 24.1.14
    committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
    branch nick: email
    timestamp: Mon 2008-12-08 18:04:31 +0100
    message:
      Fix test suite ERRORs.
      
      * testemail.py:
      (TestGetTo.get_sender): '\r' are now illegal (and cought as such)
      in commit messages (since bzr at 3854 fixing bug #295161).
    modified:
      tests/testemail.py
    ------------------------------------------------------------
    revno: 24.1.15
    committer: Robert Collins <robertc at robertcollins.net>
    branch nick: trunk
    timestamp: Wed 2008-12-10 07:09:15 +1100
    message:
      Draft support for mailing on push/pull.
    modified:
      __init__.py
      emailer.py
      tests/testemail.py
    ------------------------------------------------------------
    revno: 24.1.16
    committer: Martin Pool <mbp at sourcefrog.net>
    branch nick: 335332-starttls
    timestamp: Tue 2009-03-10 12:24:28 +1000
    message:
      Ignore failures to STARTTLS
    modified:
      smtp_connection.py
-------------- next part --------------
=== modified file '__init__.py'
--- a/__init__.py	2008-05-01 22:59:50 +0000
+++ b/__init__.py	2008-12-09 20:09:15 +0000
@@ -14,7 +14,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
-"""Sending emails upon commit with information about the commit.
+"""Sending emails for commits and branch changes.
 
 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``
@@ -27,6 +27,10 @@
 to disable the feature) by setting the configuration option
 'post_commit_difflimit' to the number of lines you wish it to be limited to.
 
+By default bzr-email only emails when a commit occurs, not when a push or
+pull operation occurs. To email on push or pull set post_commit_push_pull=True
+in the configuration.
+
 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.
@@ -37,7 +41,7 @@
  - 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
+has a private 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
@@ -46,7 +50,7 @@
  - ``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
+   "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
@@ -87,11 +91,21 @@
                          local_branch=local).send_maybe()
 
 
+def branch_post_change_hook(params):
+    """This is the post_change_branch_tip hook."""
+    # (branch, old_revno, new_revno, old_revid, new_revid)
+    _emailer.EmailSender(params.branch, params.new_revid,
+        params.branch.get_config(), local_branch=None, op='change').send_maybe()
+
+
 def install_hooks():
     """Install CommitSender to send after commits with bzr >= 0.15 """
     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')
+        if 'post_change_branch_tip' in Branch.hooks:
+            install_named_hook('post_change_branch_tip',
+                branch_post_change_hook, 'bzr-email')
     else:
         Branch.hooks.install_hook('post_commit', branch_commit_hook)
         if getattr(Branch.hooks, 'name_hook', None) is not None:

=== modified file 'debian/changelog'
--- a/debian/changelog	2008-08-05 21:03:29 +0000
+++ b/debian/changelog	2009-03-10 13:59:07 +0000
@@ -1,3 +1,9 @@
+bzr-email (0.0.1~bzr40-1) unstable; urgency=low
+
+  * New upstream snapshot.
+
+ -- Jelmer Vernooij <jelmer at debian.org>  Tue, 10 Mar 2009 14:56:23 +0100
+
 bzr-email (0.0.1~bzr34-1) unstable; urgency=low
 
   * New upstream snapshot.

=== modified file 'debian/compat'
--- a/debian/compat	2007-03-21 12:35:55 +0000
+++ b/debian/compat	2009-03-10 13:59:07 +0000
@@ -1,1 +1,1 @@
-4
+5

=== modified file 'debian/control'
--- a/debian/control	2008-08-05 21:03:47 +0000
+++ b/debian/control	2009-03-10 13:59:07 +0000
@@ -2,7 +2,7 @@
 Section: devel
 Priority: optional
 Maintainer: Debian Bazaar Maintainers <pkg-bazaar-maint at lists.alioth.debian.org>
-Uploaders: Jelmer Vernooij <jelmer at samba.org>
+Uploaders: Jelmer Vernooij <jelmer at debian.org>
 Homepage: https://launchpad.net/bzr-email
 Build-Depends-Indep: bzr (>= 1.0)
 Build-Depends: python-central (>= 0.5), cdbs (>= 0.4.43), debhelper (>= 5.0.37.2), python-dev
@@ -13,7 +13,7 @@
 
 Package: bzr-email
 Architecture: all
-Depends: bzr (>= 1.0), ${python:Depends}
+Depends: bzr (>= 1.0), ${python:Depends}, ${misc:Depends}
 Enhances: bzr
 XB-Python-Version: ${python:Versions}
 Description: Notification email plugin for Bazaar

=== modified file 'emailer.py'
--- a/emailer.py	2008-06-05 17:40:57 +0000
+++ b/emailer.py	2008-12-09 20:09:15 +0000
@@ -30,7 +30,8 @@
 
     _smtplib_implementation = SMTPConnection
 
-    def __init__(self, branch, revision_id, config, local_branch=None):
+    def __init__(self, branch, revision_id, config, local_branch=None,
+        op='commit'):
         self.config = config
         self.branch = branch
         self.repository = branch.repository
@@ -40,6 +41,7 @@
         self._revision_id = revision_id
         self.revision = None
         self.revno = None
+        self.op = op
 
     def _setup_revision_and_revno(self):
         self.revision = self.repository.get_revision(self._revision_id)
@@ -230,7 +232,16 @@
                                             self.diff_filename())
 
     def should_send(self):
-        return self.to() and self.from_address()
+        result = self.config.get_user_option('post_commit_difflimit')
+        post_commit_push_pull = self.config.get_user_option(
+            'post_commit_push_pull') == 'True'
+        if post_commit_push_pull and self.op == 'commit':
+            # We will be called again with a push op, send the mail then.
+            return False
+        if not post_commit_push_pull and self.op != 'commit':
+            # Mailing on commit only, and this is a push/pull operation.
+            return False
+        return bool(self.to() and self.from_address())
 
     def send_maybe(self):
         if self.should_send():

=== modified file 'smtp_connection.py'
--- a/smtp_connection.py	2008-04-29 14:02:52 +0000
+++ b/smtp_connection.py	2009-03-10 02:24:28 +0000
@@ -80,7 +80,16 @@
         # 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
         # to fail anyway).
-        self._connection.starttls()
+        try:
+            self._connection.starttls()
+        except smtplib.SMTPException, e:
+            if e.args[0] == 'STARTTLS extension not supported by server.':
+                # python2.6 changed to raising an exception here; we can't
+                # really do anything else without it so just continue
+                # <https://bugs.edge.launchpad.net/bzr-email/+bug/335332>
+                pass
+            else:
+                raise
 
     def _authenticate(self):
         """If necessary authenticate yourself to the server."""

=== modified file 'tests/testemail.py'
--- a/tests/testemail.py	2007-02-17 18:09:12 +0000
+++ b/tests/testemail.py	2008-12-09 20:09:15 +0000
@@ -49,6 +49,10 @@
               "post_commit_sender=Sender <from at example.com>\n"
               "post_commit_to=Sample <foo at example.com>, Other <baz at bar.com>\n")
 
+push_config=("[DEFAULT]\n"
+    "post_commit_to=demo at example.com\n"
+    "post_commit_push_pull=True\n")
+
 with_url_config=("[DEFAULT]\n"
                  "post_commit_url=http://some.fake/url/\n"
                  "post_commit_to=demo at example.com\n"
@@ -149,7 +153,7 @@
     def get_sender(self, text=sample_config):
         self.branch = BzrDir.create_branch_convenience('.')
         tree = self.branch.bzrdir.open_workingtree()
-        tree.commit('foo bar baz\nfuzzy\rwuzzy', rev_id='A',
+        tree.commit('foo bar baz\nfuzzy\nwuzzy', rev_id='A',
             allow_pointless=True,
             timestamp=1,
             timezone=0,



More information about the Pkg-bazaar-commits mailing list