[PATCH STABLE] py3: decode Subject header in patchbomb
Denis Laxalde
denis at laxalde.org
Tue Oct 29 13:19:46 EDT 2019
# HG changeset patch
# User Denis Laxalde <denis at laxalde.org>
# Date 1572369108 -3600
# Tue Oct 29 18:11:48 2019 +0100
# Branch stable
# Node ID 305a12fc7cc8bed4a9dd95e91de3747ba6daf8ce
# Parent 17fad3f1b4742d75db23e17a04c85223bcc239a2
py3: decode Subject header in patchbomb
This fixes a crash on Python 3 when using non-ascii characters in commit
message (or subject header, e.g., in introduction message). A test was
introduced in previous changeset.
diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py
--- a/hgext/patchbomb.py
+++ b/hgext/patchbomb.py
@@ -321,7 +321,9 @@ def makepatch(
subj = b' '.join([prefix, opts.get(b'subject') or subj])
else:
subj = b' '.join([prefix, subj])
- msg[b'Subject'] = mail.headencode(ui, subj, _charsets, opts.get(b'test'))
+ msg[b'Subject'] = encoding.strfromlocal(
+ mail.headencode(ui, subj, _charsets, opts.get(b'test'))
+ )
msg[b'X-Mercurial-Node'] = node
msg[b'X-Mercurial-Series-Index'] = b'%i' % idx
msg[b'X-Mercurial-Series-Total'] = b'%i' % total
@@ -454,7 +456,9 @@ def _makeintro(repo, sender, revs, patch
body = _getdescription(repo, body, sender, **opts)
msg = mail.mimeencode(ui, body, _charsets, opts.get(r'test'))
- msg[b'Subject'] = mail.headencode(ui, subj, _charsets, opts.get(r'test'))
+ msg[b'Subject'] = encoding.strfromlocal(
+ mail.headencode(ui, subj, _charsets, opts.get(r'test'))
+ )
return (msg, subj, diffstat)
More information about the Mercurial-devel
mailing list