##// END OF EJS Templates
mail: use a native string for "subtype" value...
Denis Laxalde -
r44026:af3e341d default
parent child Browse files
Show More
@@ -285,7 +285,7 b' def makepatch('
285 if body:
285 if body:
286 msg.attach(mail.mimeencode(ui, body, _charsets, opts.get(b'test')))
286 msg.attach(mail.mimeencode(ui, body, _charsets, opts.get(b'test')))
287 p = mail.mimetextpatch(
287 p = mail.mimetextpatch(
288 b'\n'.join(patchlines), b'x-patch', opts.get(b'test')
288 b'\n'.join(patchlines), 'x-patch', opts.get(b'test')
289 )
289 )
290 binnode = nodemod.bin(node)
290 binnode = nodemod.bin(node)
291 # if node is mq patch, it will have the patch file's name as a tag
291 # if node is mq patch, it will have the patch file's name as a tag
@@ -263,8 +263,8 b' def codec2iana(cs):'
263 return cs
263 return cs
264
264
265
265
266 def mimetextpatch(s, subtype=b'plain', display=False):
266 def mimetextpatch(s, subtype='plain', display=False):
267 # type: (bytes, bytes, bool) -> email.message.Message
267 # type: (bytes, str, bool) -> email.message.Message
268 '''Return MIME message suitable for a patch.
268 '''Return MIME message suitable for a patch.
269 Charset will be detected by first trying to decode as us-ascii, then utf-8,
269 Charset will be detected by first trying to decode as us-ascii, then utf-8,
270 and finally the global encodings. If all those fail, fall back to
270 and finally the global encodings. If all those fail, fall back to
@@ -290,13 +290,13 b" def mimetextpatch(s, subtype=b'plain', d"
290
290
291
291
292 def mimetextqp(body, subtype, charset):
292 def mimetextqp(body, subtype, charset):
293 # type: (bytes, bytes, str) -> email.message.Message
293 # type: (bytes, str, str) -> email.message.Message
294 '''Return MIME message.
294 '''Return MIME message.
295 Quoted-printable transfer encoding will be used if necessary.
295 Quoted-printable transfer encoding will be used if necessary.
296 '''
296 '''
297 cs = email.charset.Charset(charset)
297 cs = email.charset.Charset(charset)
298 msg = email.message.Message()
298 msg = email.message.Message()
299 msg.set_type(pycompat.sysstr(b'text/' + subtype))
299 msg.set_type('text/' + subtype)
300
300
301 for line in body.splitlines():
301 for line in body.splitlines():
302 if len(line) > 950:
302 if len(line) > 950:
@@ -450,7 +450,7 b' def mimeencode(ui, s, charsets=None, dis'
450 cs = 'us-ascii'
450 cs = 'us-ascii'
451 if not display:
451 if not display:
452 s, cs = _encode(ui, s, charsets)
452 s, cs = _encode(ui, s, charsets)
453 return mimetextqp(s, b'plain', cs)
453 return mimetextqp(s, 'plain', cs)
454
454
455
455
456 if pycompat.ispy3:
456 if pycompat.ispy3:
General Comments 0
You need to be logged in to leave comments. Login now