# HG changeset patch # User Denis Laxalde # Date 2019-10-10 08:53:13 # Node ID 3460eee570f7c71253bb6a875de7b920dbaa44cb # Parent 0e6a7ce81dde091383463ef358de8299bac92b7a patchbomb: use mail.Generator alias for py2/py3 compat diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py --- a/hgext/patchbomb.py +++ b/hgext/patchbomb.py @@ -74,7 +74,6 @@ You can set patchbomb to always ask for 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 @@ configitem( 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 @@ def email(ui, repo, *revs, **opts): 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 @@ def email(ui, repo, *revs, **opts): # 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]