# HG changeset patch # User Denis Laxalde <denis.laxa...@logilab.fr> # Date 1573654984 -3600 # Wed Nov 13 15:23:04 2019 +0100 # Node ID 6f035c6bb911f36cd2459272843388a218be120d # Parent f84d980d58cd3e1bdf2b19aa03b419e438eff808 mail: use a native string for "subtype" value
This is somehow similar to previous changeset and avoids one str conversion. diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py --- a/hgext/patchbomb.py +++ b/hgext/patchbomb.py @@ -285,7 +285,7 @@ def makepatch( if body: msg.attach(mail.mimeencode(ui, body, _charsets, opts.get(b'test'))) p = mail.mimetextpatch( - b'\n'.join(patchlines), b'x-patch', opts.get(b'test') + b'\n'.join(patchlines), 'x-patch', opts.get(b'test') ) binnode = nodemod.bin(node) # if node is mq patch, it will have the patch file's name as a tag diff --git a/mercurial/mail.py b/mercurial/mail.py --- a/mercurial/mail.py +++ b/mercurial/mail.py @@ -263,8 +263,8 @@ def codec2iana(cs): return cs -def mimetextpatch(s, subtype=b'plain', display=False): - # type: (bytes, bytes, bool) -> email.message.Message +def mimetextpatch(s, subtype='plain', display=False): + # type: (bytes, str, bool) -> email.message.Message '''Return MIME message suitable for a patch. Charset will be detected by first trying to decode as us-ascii, then utf-8, and finally the global encodings. If all those fail, fall back to @@ -290,13 +290,13 @@ def mimetextpatch(s, subtype=b'plain', d def mimetextqp(body, subtype, charset): - # type: (bytes, bytes, str) -> email.message.Message + # type: (bytes, str, str) -> email.message.Message '''Return MIME message. Quoted-printable transfer encoding will be used if necessary. ''' cs = email.charset.Charset(charset) msg = email.message.Message() - msg.set_type(pycompat.sysstr(b'text/' + subtype)) + msg.set_type('text/' + subtype) for line in body.splitlines(): if len(line) > 950: @@ -450,7 +450,7 @@ def mimeencode(ui, s, charsets=None, dis cs = 'us-ascii' if not display: s, cs = _encode(ui, s, charsets) - return mimetextqp(s, b'plain', cs) + return mimetextqp(s, 'plain', cs) if pycompat.ispy3: _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel