Merge lp:~jteh/bzr-email/fix0difflimit into lp:bzr-email

Proposed by James Teh
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: 42
Merged at revision: 43
Proposed branch: lp:~jteh/bzr-email/fix0difflimit
Merge into: lp:bzr-email
Diff against target: 50 lines (+14/-8)
2 files modified
__init__.py (+4/-4)
emailer.py (+10/-4)
To merge this branch: bzr merge lp:~jteh/bzr-email/fix0difflimit
Reviewer Review Type Date Requested Status
Robert Collins (community) Approve
Review via email: mp+20053@code.launchpad.net

Commit message

Gracefully handle (and clarify documentation about) difflimit being set to 0 to indicate that diffs should not be included.

To post a comment you must log in.
Revision history for this message
Robert Collins (lifeless) wrote :

 review: approve

review: Approve
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

I'll merge this, as Rob has already approved it earlier.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '__init__.py'
2--- __init__.py 2008-12-09 20:09:15 +0000
3+++ __init__.py 2010-02-24 12:41:16 +0000
4@@ -22,10 +22,10 @@
5 ``post_commit_sender`` (if not supplied defaults to the email address reported
6 by ``bzr whoami``).
7
8-By default, the diff for the commit will be included in the email, if the
9-length is less than 1000 lines. This limit can be changed (for instance, to 0
10-to disable the feature) by setting the configuration option
11-'post_commit_difflimit' to the number of lines you wish it to be limited to.
12+By default, the diff for the commit will be included in the email if the
13+length is less than 1000 lines. This limit can be changed by setting the
14+configuration option 'post_commit_difflimit' to the number of lines you wish
15+it to be limited to. Set it to 0 to unconditionally disable sending of diffs.
16
17 By default bzr-email only emails when a commit occurs, not when a push or
18 pull operation occurs. To email on push or pull set post_commit_push_pull=True
19
20=== modified file 'emailer.py'
21--- emailer.py 2008-12-09 20:09:15 +0000
22+++ emailer.py 2010-02-24 12:41:16 +0000
23@@ -195,7 +195,10 @@
24 process = subprocess.Popen(self._command_line(),
25 stdin=subprocess.PIPE)
26 try:
27- message = self.body().encode('utf8') + self.get_diff()
28+ message = self.body().encode('utf8')
29+ diff = self.get_diff()
30+ if diff:
31+ message += diff
32 result = process.communicate(message)[0]
33 if process.returncode is None:
34 process.wait()
35@@ -227,9 +230,12 @@
36 to_addrs = [to_addrs]
37
38 smtp = self._smtplib_implementation(self.config)
39- smtp.send_text_and_attachment_email(from_addr, to_addrs,
40- subject, body, diff,
41- self.diff_filename())
42+ if diff:
43+ smtp.send_text_and_attachment_email(from_addr, to_addrs,
44+ subject, body, diff,
45+ self.diff_filename())
46+ else:
47+ smtp.send_text_email(from_addr, to_addrs, subject, body)
48
49 def should_send(self):
50 result = self.config.get_user_option('post_commit_difflimit')

Subscribers

People subscribed via source and target branches

to all changes: