patchbomb: really use BytesGenerator API
authorYuya Nishihara <yuya@tcha.org>
Sun, 12 Aug 2018 11:43:24 +0900
changeset 39104 2e578eced958
parent 39103 da130c5cef90
child 39105 f68ad9b4a43b
patchbomb: really use BytesGenerator API It wraps around Generator type.
hgext/patchbomb.py
--- 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]