mercurial/mdiff.py
changeset 36414 44c4a38bf563
parent 36146 29dd37a418aa
child 36607 c6061cadb400
--- a/mercurial/mdiff.py	Sun Feb 25 11:20:35 2018 +0900
+++ b/mercurial/mdiff.py	Fri Feb 23 23:09:58 2018 +0900
@@ -13,6 +13,7 @@
 
 from .i18n import _
 from . import (
+    encoding,
     error,
     policy,
     pycompat,
@@ -348,7 +349,11 @@
             # alphanumeric char.
             for i in xrange(astart - 1, lastpos - 1, -1):
                 if l1[i][0:1].isalnum():
-                    func = ' ' + l1[i].rstrip()[:40]
+                    func = b' ' + l1[i].rstrip()
+                    # split long function name if ASCII. otherwise we have no
+                    # idea where the multi-byte boundary is, so just leave it.
+                    if encoding.isasciistr(func):
+                        func = func[:41]
                     lastfunc[1] = func
                     break
             # by recording this hunk's starting point as the next place to