Merge lp:~thumper/launchpad/initial-mp-email-text-alignment into lp:launchpad

Proposed by Tim Penhey
Status: Merged
Approved by: Tim Penhey
Approved revision: not available
Merged at revision: 10316
Proposed branch: lp:~thumper/launchpad/initial-mp-email-text-alignment
Merge into: lp:launchpad
Diff against target: 88 lines (+48/-7)
2 files modified
lib/lp/code/mail/branchmergeproposal.py (+30/-6)
lib/lp/code/mail/tests/test_branchmergeproposal.py (+18/-1)
To merge this branch: bzr merge lp:~thumper/launchpad/initial-mp-email-text-alignment
Reviewer Review Type Date Requested Status
Michael Hudson-Doyle Approve
Review via email: mp+19303@code.launchpad.net

Commit message

Fix the alignment of the related bugs and requested reviews in the initial merge proposal email.

To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) wrote :

A simple fix to the outgoing email for a new merge proposal to make sure that the related bugs and requested reviews use the same formatting.

Revision history for this message
Michael Hudson-Doyle (mwhudson) wrote :

Looks fine to me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/code/mail/branchmergeproposal.py'
--- lib/lp/code/mail/branchmergeproposal.py 2009-11-12 21:27:16 +0000
+++ lib/lp/code/mail/branchmergeproposal.py 2010-02-14 22:36:21 +0000
@@ -237,9 +237,36 @@
237 params['diff_cutoff_warning'] = (237 params['diff_cutoff_warning'] = (
238 "The attached diff has been truncated due to its size.")238 "The attached diff has been truncated due to its size.")
239239
240 params['reviews'] = self._getRequestedReviews()
240 params['related_bugs'] = self._getRelatedBugs()241 params['related_bugs'] = self._getRelatedBugs()
241 return params242 return params
242243
244 def _formatExtraInformation(self, heading, chunks):
245 """Consistently indent the chunks with the heading.
246
247 Used to provide consistent indentation for requested reviews and
248 related bugs.
249 """
250 if len(chunks) == 0:
251 return ''
252 else:
253 info = ''.join(' %s\n' % value for value in chunks)
254 return '%s\n%s' % (heading, info)
255
256 def _getRequestedReviews(self):
257 """Return a string describing the requested reviews, if any."""
258 requested_reviews = []
259 for review in self.requested_reviews:
260 reviewer = review.reviewer
261 if review.review_type is None:
262 requested_reviews.append(reviewer.unique_displayname)
263 else:
264 requested_reviews.append(
265 "%s: %s" % (reviewer.unique_displayname,
266 review.review_type))
267 return self._formatExtraInformation(
268 'Requested reviews:', requested_reviews)
269
243 def _getRelatedBugs(self):270 def _getRelatedBugs(self):
244 """Return a string describing related bugs, if any.271 """Return a string describing related bugs, if any.
245272
@@ -247,12 +274,9 @@
247 """274 """
248 bug_chunks = []275 bug_chunks = []
249 for bug in self.merge_proposal.related_bugs:276 for bug in self.merge_proposal.related_bugs:
250 bug_chunks.append(' #%d %s\n' % (bug.id, bug.title))277 bug_chunks.append('#%d %s' % (bug.id, bug.title))
251 bug_chunks.append(' %s\n' % canonical_url(bug))278 bug_chunks.append(canonical_url(bug))
252 if len(bug_chunks) == 0:279 return self._formatExtraInformation('Related bugs:', bug_chunks)
253 return ''
254 else:
255 return 'Related bugs:\n' + ''.join(bug_chunks)
256280
257 def _getTemplateParams(self, email):281 def _getTemplateParams(self, email):
258 """Return a dict of values to use in the body and subject."""282 """Return a dict of values to use in the body and subject."""
259283
=== modified file 'lib/lp/code/mail/tests/test_branchmergeproposal.py'
--- lib/lp/code/mail/tests/test_branchmergeproposal.py 2009-10-28 20:13:39 +0000
+++ lib/lp/code/mail/tests/test_branchmergeproposal.py 2010-02-14 22:36:21 +0000
@@ -135,9 +135,26 @@
135 mailer = BMPMailer.forCreation(bmp, bmp.registrant)135 mailer = BMPMailer.forCreation(bmp, bmp.registrant)
136 ctrl = mailer.generateEmail('baz.quxx@example.com', subscriber)136 ctrl = mailer.generateEmail('baz.quxx@example.com', subscriber)
137 self.assertIn(137 self.assertIn(
138 'Requested reviews:\n Review-person (review-person)\n\n-- \n',138 '\nRequested reviews:\n Review-person (review-person)\n\n-- \n',
139 ctrl.body)139 ctrl.body)
140140
141 def test_forCreation_with_review_request_and_bug(self):
142 """Correctly format list of reviewers and bug info."""
143 bmp, subscriber = self.makeProposalWithSubscriber()
144 bug = self.factory.makeBug(title='I am a bug')
145 bmp.source_branch.linkBug(bug, bmp.registrant)
146 reviewer = self.factory.makePerson(name='review-person')
147 vote_reference = bmp.nominateReviewer(reviewer, bmp.registrant, None)
148 mailer = BMPMailer.forCreation(bmp, bmp.registrant)
149 ctrl = mailer.generateEmail('baz.quxx@example.com', subscriber)
150 expected = (
151 '\nRequested reviews:'
152 '\n Review-person (review-person)'
153 '\nRelated bugs:'
154 '\n #%d I am a bug'
155 '\n %s\n\n--' % (bug.id, canonical_url(bug)))
156 self.assertIn(expected, ctrl.body)
157
141 def test_forCreation_with_prerequisite_branch(self):158 def test_forCreation_with_prerequisite_branch(self):
142 """Correctly format list of reviewers."""159 """Correctly format list of reviewers."""
143 bmp, subscriber = self.makeProposalWithSubscriber(prerequisite=True)160 bmp, subscriber = self.makeProposalWithSubscriber(prerequisite=True)