diff mercurial/filemerge.py @ 21865:78e56e70c70a

filemerge: use 'util.ellipsis' to trim custom conflict markers correctly Before this patch, filemerge slices byte sequence directly to trim conflict markers, but this may cause: - splitting at intermediate multi-byte sequence - incorrect calculation of column width (length of byte sequence is different from columns in display in many cases) This patch uses 'util.ellipsis' to trim custom conflict markers correctly, even if multi-byte characters are used in them.
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Sun, 06 Jul 2014 02:56:41 +0900
parents 755bf1bbe0a9
children 10abc3a5c6b2
line wrap: on
line diff
--- a/mercurial/filemerge.py	Sun Jul 06 02:56:41 2014 +0900
+++ b/mercurial/filemerge.py	Sun Jul 06 02:56:41 2014 +0900
@@ -290,12 +290,8 @@
     if mark:
         mark = mark.splitlines()[0] # split for safety
 
-    # The <<< marks add 8 to the length, and '...' adds three, so max
-    # length of the actual marker is 69.
-    maxlength = 80 - 8 - 3
-    if len(mark) > maxlength:
-        mark = mark[:maxlength] + '...'
-    return mark
+    # 8 for the prefix of conflict marker lines (e.g. '<<<<<<< ')
+    return util.ellipsis(mark, 80 - 8)
 
 _defaultconflictmarker = ('{node|short} ' +
     '{ifeq(tags, "tip", "", "{tags} ")}' +