On py2:
import email
import email.generator as emailgen
email.Generator.Generator is emailgen.Generator
True
email.Generator is not present on Python 3.
hg-reviewers |
On py2:
import email
import email.generator as emailgen
email.Generator.Generator is emailgen.Generator
True
email.Generator is not present on Python 3.
Lint Skipped |
Unit Tests Skipped |
flags)}" | flags)}" | ||||
You can set patchbomb to always ask for confirmation by setting | You can set patchbomb to always ask for confirmation by setting | ||||
``patchbomb.confirm`` to true. | ``patchbomb.confirm`` to true. | ||||
''' | ''' | ||||
from __future__ import absolute_import | from __future__ import absolute_import | ||||
import email as emailmod | import email as emailmod | ||||
import email.generator as emailgen | |||||
import email.utils as eutil | import email.utils as eutil | ||||
import errno | import errno | ||||
import os | import os | ||||
import socket | import socket | ||||
import tempfile | import tempfile | ||||
from mercurial.i18n import _ | from mercurial.i18n import _ | ||||
from mercurial import ( | from mercurial import ( | ||||
m['Cc'] = ', '.join(cc) | m['Cc'] = ', '.join(cc) | ||||
if bcc: | if bcc: | ||||
m['Bcc'] = ', '.join(bcc) | m['Bcc'] = ', '.join(bcc) | ||||
if replyto: | if replyto: | ||||
m['Reply-To'] = ', '.join(replyto) | m['Reply-To'] = ', '.join(replyto) | ||||
if opts.get('test'): | if opts.get('test'): | ||||
ui.status(_('displaying '), subj, ' ...\n') | ui.status(_('displaying '), subj, ' ...\n') | ||||
ui.pager('email') | ui.pager('email') | ||||
generator = emailmod.Generator.Generator(ui, mangle_from_=False) | generator = emailgen.Generator(ui, mangle_from_=False) | ||||
try: | try: | ||||
generator.flatten(m, 0) | generator.flatten(m, 0) | ||||
ui.write('\n') | ui.write('\n') | ||||
except IOError as inst: | except IOError as inst: | ||||
if inst.errno != errno.EPIPE: | if inst.errno != errno.EPIPE: | ||||
raise | raise | ||||
else: | else: | ||||
if not sendmail: | if not sendmail: | ||||
sendmail = mail.connect(ui, mbox=mbox) | sendmail = mail.connect(ui, mbox=mbox) | ||||
ui.status(_('sending '), subj, ' ...\n') | ui.status(_('sending '), subj, ' ...\n') | ||||
ui.progress(_('sending'), i, item=subj, total=len(msgs), | ui.progress(_('sending'), i, item=subj, total=len(msgs), | ||||
unit=_('emails')) | unit=_('emails')) | ||||
if not mbox: | if not mbox: | ||||
# Exim does not remove the Bcc field | # Exim does not remove the Bcc field | ||||
del m['Bcc'] | del m['Bcc'] | ||||
fp = stringio() | fp = stringio() | ||||
generator = emailmod.Generator.Generator(fp, mangle_from_=False) | generator = emailgen.Generator(fp, mangle_from_=False) | ||||
generator.flatten(m, 0) | generator.flatten(m, 0) | ||||
sendmail(sender_addr, to + bcc + cc, fp.getvalue()) | sendmail(sender_addr, to + bcc + cc, fp.getvalue()) | ||||
ui.progress(_('writing'), None) | ui.progress(_('writing'), None) | ||||
ui.progress(_('sending'), None) | ui.progress(_('sending'), None) |