# HG changeset patch
# User Yuya Nishihara <y...@tcha.org>
# Date 1523076157 -32400
#      Sat Apr 07 13:42:37 2018 +0900
# Node ID e500a16779ebbd095bacc793a42ff57a91c47737
# Parent  5f401721fa2a4ba1e5b5ea570c9c0978481a20f7
py3: convert parsed message items to bytes in patch.extract()

Appears that BytesParser() parses bytes into unicode, sigh.

diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -228,7 +228,8 @@ def extract(ui, fileobj):
         data['user'] = msg['From'] and mail.headdecode(msg['From'])
         if not subject and not data['user']:
             # Not an email, restore parsed headers if any
-            subject = '\n'.join(': '.join(h) for h in msg.items()) + '\n'
+            subject = '\n'.join(': '.join(map(encoding.strtolocal, h))
+                                for h in msg.items()) + '\n'
 
         # should try to parse msg['Date']
         parents = []
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to