/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/merge_directive.py

  • Committer: Adeodato Simó
  • Date: 2007-07-18 15:51:52 UTC
  • mto: (2639.1.1 jam-integration)
  • mto: This revision was merged to the branch mainline in revision 2640.
  • Revision ID: dato@net.com.org.es-20070718155152-pv6rwq41eckqyxem
New EmailMessage class, façade around email.Message and MIMEMultipart.

* bzrlib/email_message.py,
  bzrlib/tests/test_email_message.py:
  New files.

* bzrlib/tests/__init__.py:
  (test_suite): add bzrlib.tests.test_email_message.

* bzrlib/merge_directive.py:
  (MergeDirective.to_email): Use EmailMessage instead of email.Message.

* bzrlib/tests/test_merge_directive.py,
  bzrlib/tests/blackbox/test_merge_directive.py:
  (__main__): adjust EMAIL1 and EMAIL2 strings to how EmailMessage
  formats itself.

* bzrlib/smtp_connection.py:
  (SMTPConnection.get_message_addresses): do not use methods present in
  email.Message but not in EmailMessage (get_all). Use get() instead of
  __getitem__ to make explicit that None is returned if the header does
  not exist.

* bzrlib/tests/test_smtp_connection.py:
  (TestSMTPConnection.test_get_message_addresses, 
   TestSMTPConnection.test_destination_address_required): test the
   functions against EmailMessage in addition to email.Message.

* NEWS:
  Mention EmailMessage in INTERNALS.

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
 
18
 
from email import Message
19
18
from StringIO import StringIO
20
19
 
21
20
from bzrlib import (
31
30
from bzrlib.bundle import (
32
31
    serializer as bundle_serializer,
33
32
    )
 
33
from bzrlib.email_message import EmailMessage
34
34
 
35
35
 
36
36
class MergeDirective(object):
163
163
        :return: an email message
164
164
        """
165
165
        mail_from = branch.get_config().username()
166
 
        message = Message.Message()
167
 
        message['To'] = mail_to
168
 
        message['From'] = mail_from
169
166
        if self.message is not None:
170
 
            message['Subject'] = self.message
 
167
            subject = self.message
171
168
        else:
172
169
            revision = branch.repository.get_revision(self.revision_id)
173
 
            message['Subject'] = revision.message
 
170
            subject = revision.message
174
171
        if sign:
175
172
            body = self.to_signed(branch)
176
173
        else:
177
174
            body = ''.join(self.to_lines())
178
 
        message.set_payload(body)
 
175
        message = EmailMessage(mail_from, mail_to, subject, body)
179
176
        return message
180
177
 
181
178
    @classmethod