Rev 45: Fix bug #160530, don't use proper email subject lines, as the PQM bot doesn't understand them. in http://bazaar.launchpad.net/%7Ebzr-pqm-devel/bzr-pqm/devel
John Arbash Meinel
john at arbash-meinel.com
Tue Nov 6 17:20:51 GMT 2007
At http://bazaar.launchpad.net/%7Ebzr-pqm-devel/bzr-pqm/devel
------------------------------------------------------------
revno: 45
revision-id:john at arbash-meinel.com-20071106172032-zl3c2h2h5fnhqgx7
parent: john at arbash-meinel.com-20071106035927-akvtsswk9zlcohou
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: pqm
timestamp: Tue 2007-11-06 11:20:32 -0600
message:
Fix bug #160530, don't use proper email subject lines, as the PQM bot doesn't understand them.
modified:
pqm_submit.py pqm_submit.py-20060221060137-b3a3cdde9f50efab
test_pqm_submit.py test_pqm_submit.py-20060221060137-fb48d47216aa0077
-------------- next part --------------
=== modified file 'pqm_submit.py'
--- a/pqm_submit.py 2007-11-06 03:55:54 +0000
+++ b/pqm_submit.py 2007-11-06 17:20:32 +0000
@@ -37,6 +37,17 @@
self.msg = message
+class PQMEmailMessage(EmailMessage):
+ """PQM doesn't support proper email subjects, so we hack around it."""
+
+ def __init__(self, from_address, to_address, subject, body=None):
+ EmailMessage.__init__(self, from_address=from_address,
+ to_address=to_address, subject=subject,
+ body=body)
+ # Now override self.Subject to use raw utf-8
+ self._headers['Subject'] = osutils.safe_unicode(subject).encode('UTF-8')
+
+
class PQMSubmission(object):
"""A request to perform a PQM merge into a branch."""
@@ -157,7 +168,7 @@
body = self.to_signed()
else:
body = ''.join(self.to_lines())
- message = EmailMessage(mail_from, mail_to, self.message, body)
+ message = PQMEmailMessage(mail_from, mail_to, self.message, body)
return message
=== modified file 'test_pqm_submit.py'
--- a/test_pqm_submit.py 2007-11-06 03:59:27 +0000
+++ b/test_pqm_submit.py 2007-11-06 17:20:32 +0000
@@ -167,6 +167,21 @@
self.assertEqual('to at example.com', message.get('To'))
self.assertEqual('commit message', message.get('Subject'))
+ def test_to_unicode_email(self):
+ """Subject has to be raw UTF-8 not email encoded."""
+ source_branch = self.make_branch('source')
+ submission = pqm_submit.PQMSubmission(
+ source_branch=source_branch,
+ public_location='public-branch',
+ submit_location='submit-branch',
+ message=u'Commit m\xe5ss\xb5ge')
+ message = submission.to_email('from at example.com', 'to at example.com',
+ sign=False)
+ self.assertEqual('from at example.com', message.get('From'))
+ self.assertEqual('to at example.com', message.get('To'))
+ self.assertEqual('Commit m\xc3\xa5ss\xc2\xb5ge',
+ message.get('Subject'))
+
class PQMSubmissionLocationsTests(TestCaseWithTransport):
More information about the bazaar-commits
mailing list