##// END OF EJS Templates
patchbomb: use mail.Generator alias for py2/py3 compat
Denis Laxalde -
r43427:3460eee5 default
parent child Browse files
Show More
@@ -74,7 +74,6 b' You can set patchbomb to always ask for '
74 from __future__ import absolute_import
74 from __future__ import absolute_import
75
75
76 import email.encoders as emailencoders
76 import email.encoders as emailencoders
77 import email.generator as emailgen
78 import email.mime.base as emimebase
77 import email.mime.base as emimebase
79 import email.mime.multipart as emimemultipart
78 import email.mime.multipart as emimemultipart
80 import email.utils as eutil
79 import email.utils as eutil
@@ -141,11 +140,6 b' configitem('
141 b'patchbomb', b'to', default=None,
140 b'patchbomb', b'to', default=None,
142 )
141 )
143
142
144 if pycompat.ispy3:
145 _bytesgenerator = emailgen.BytesGenerator
146 else:
147 _bytesgenerator = emailgen.Generator
148
149 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
143 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
150 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
144 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
151 # be specifying the version(s) of Mercurial they are tested with, or
145 # be specifying the version(s) of Mercurial they are tested with, or
@@ -976,7 +970,7 b' def email(ui, repo, *revs, **opts):'
976 if opts.get(b'test'):
970 if opts.get(b'test'):
977 ui.status(_(b'displaying '), subj, b' ...\n')
971 ui.status(_(b'displaying '), subj, b' ...\n')
978 ui.pager(b'email')
972 ui.pager(b'email')
979 generator = _bytesgenerator(ui, mangle_from_=False)
973 generator = mail.Generator(ui, mangle_from_=False)
980 try:
974 try:
981 generator.flatten(m, 0)
975 generator.flatten(m, 0)
982 ui.write(b'\n')
976 ui.write(b'\n')
@@ -992,7 +986,7 b' def email(ui, repo, *revs, **opts):'
992 # Exim does not remove the Bcc field
986 # Exim does not remove the Bcc field
993 del m[b'Bcc']
987 del m[b'Bcc']
994 fp = stringio()
988 fp = stringio()
995 generator = _bytesgenerator(fp, mangle_from_=False)
989 generator = mail.Generator(fp, mangle_from_=False)
996 generator.flatten(m, 0)
990 generator.flatten(m, 0)
997 alldests = to + bcc + cc
991 alldests = to + bcc + cc
998 alldests = [encoding.strfromlocal(d) for d in alldests]
992 alldests = [encoding.strfromlocal(d) for d in alldests]
General Comments 0
You need to be logged in to leave comments. Login now