changeset 43157:3460eee570f7

patchbomb: use mail.Generator alias for py2/py3 compat
author Denis Laxalde <denis.laxalde@logilab.fr>
date Thu, 10 Oct 2019 10:53:13 +0200
parents 0e6a7ce81dde
children ff615b6b5b8f
files hgext/patchbomb.py
diffstat 1 files changed, 2 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/patchbomb.py	Thu Oct 10 10:48:57 2019 +0200
+++ b/hgext/patchbomb.py	Thu Oct 10 10:53:13 2019 +0200
@@ -74,7 +74,6 @@
 from __future__ import absolute_import
 
 import email.encoders as emailencoders
-import email.generator as emailgen
 import email.mime.base as emimebase
 import email.mime.multipart as emimemultipart
 import email.utils as eutil
@@ -141,11 +140,6 @@
     b'patchbomb', b'to', default=None,
 )
 
-if pycompat.ispy3:
-    _bytesgenerator = emailgen.BytesGenerator
-else:
-    _bytesgenerator = emailgen.Generator
-
 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
 # be specifying the version(s) of Mercurial they are tested with, or
@@ -976,7 +970,7 @@
         if opts.get(b'test'):
             ui.status(_(b'displaying '), subj, b' ...\n')
             ui.pager(b'email')
-            generator = _bytesgenerator(ui, mangle_from_=False)
+            generator = mail.Generator(ui, mangle_from_=False)
             try:
                 generator.flatten(m, 0)
                 ui.write(b'\n')
@@ -992,7 +986,7 @@
                 # Exim does not remove the Bcc field
                 del m[b'Bcc']
             fp = stringio()
-            generator = _bytesgenerator(fp, mangle_from_=False)
+            generator = mail.Generator(fp, mangle_from_=False)
             generator.flatten(m, 0)
             alldests = to + bcc + cc
             alldests = [encoding.strfromlocal(d) for d in alldests]