changeset 39141:2e578eced958

patchbomb: really use BytesGenerator API It wraps around Generator type.
author Yuya Nishihara <yuya@tcha.org>
date Sun, 12 Aug 2018 11:43:24 +0900
parents da130c5cef90
children f68ad9b4a43b
files hgext/patchbomb.py
diffstat 1 files changed, 3 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/patchbomb.py	Sun Aug 12 14:03:22 2018 +0900
+++ b/hgext/patchbomb.py	Sun Aug 12 11:43:24 2018 +0900
@@ -142,7 +142,7 @@
 if pycompat.ispy3:
     _bytesgenerator = emailgen.BytesGenerator
 else:
-    _bytesgenerator = lambda f: f
+    _bytesgenerator = emailgen.Generator
 
 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
 # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should
@@ -806,8 +806,7 @@
         if opts.get('test'):
             ui.status(_('displaying '), subj, ' ...\n')
             ui.pager('email')
-            generator = emailgen.Generator(_bytesgenerator(ui),
-                                           mangle_from_=False)
+            generator = _bytesgenerator(ui, mangle_from_=False)
             try:
                 generator.flatten(m, 0)
                 ui.write('\n')
@@ -823,8 +822,7 @@
                 # Exim does not remove the Bcc field
                 del m['Bcc']
             fp = stringio()
-            generator = emailgen.Generator(_bytesgenerator(fp),
-                                           mangle_from_=False)
+            generator = _bytesgenerator(fp, mangle_from_=False)
             generator.flatten(m, 0)
             alldests = to + bcc + cc
             alldests = [encoding.strfromlocal(d) for d in alldests]