~ubuntu-branches/debian/squeeze/bzr-email/squeeze

« back to all changes in this revision

Viewing changes to emailer.py

  • Committer: Bazaar Package Importer
  • Author(s): Jelmer Vernooij
  • Date: 2009-03-10 14:56:23 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090310145623-g4g2xznf2unkj9dr
Tags: 0.0.1~bzr40-1
New upstream snapshot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
 
31
31
    _smtplib_implementation = SMTPConnection
32
32
 
33
 
    def __init__(self, branch, revision_id, config, local_branch=None):
 
33
    def __init__(self, branch, revision_id, config, local_branch=None,
 
34
        op='commit'):
34
35
        self.config = config
35
36
        self.branch = branch
36
37
        self.repository = branch.repository
40
41
        self._revision_id = revision_id
41
42
        self.revision = None
42
43
        self.revno = None
 
44
        self.op = op
43
45
 
44
46
    def _setup_revision_and_revno(self):
45
47
        self.revision = self.repository.get_revision(self._revision_id)
230
232
                                            self.diff_filename())
231
233
 
232
234
    def should_send(self):
233
 
        return self.to() and self.from_address()
 
235
        result = self.config.get_user_option('post_commit_difflimit')
 
236
        post_commit_push_pull = self.config.get_user_option(
 
237
            'post_commit_push_pull') == 'True'
 
238
        if post_commit_push_pull and self.op == 'commit':
 
239
            # We will be called again with a push op, send the mail then.
 
240
            return False
 
241
        if not post_commit_push_pull and self.op != 'commit':
 
242
            # Mailing on commit only, and this is a push/pull operation.
 
243
            return False
 
244
        return bool(self.to() and self.from_address())
234
245
 
235
246
    def send_maybe(self):
236
247
        if self.should_send():