comparison 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
comparison
equal deleted inserted replaced
21864:755bf1bbe0a9 21865:78e56e70c70a
288 mark = '%s %s' % (label, templater.stringify(templateresult)) 288 mark = '%s %s' % (label, templater.stringify(templateresult))
289 289
290 if mark: 290 if mark:
291 mark = mark.splitlines()[0] # split for safety 291 mark = mark.splitlines()[0] # split for safety
292 292
293 # The <<< marks add 8 to the length, and '...' adds three, so max 293 # 8 for the prefix of conflict marker lines (e.g. '<<<<<<< ')
294 # length of the actual marker is 69. 294 return util.ellipsis(mark, 80 - 8)
295 maxlength = 80 - 8 - 3
296 if len(mark) > maxlength:
297 mark = mark[:maxlength] + '...'
298 return mark
299 295
300 _defaultconflictmarker = ('{node|short} ' + 296 _defaultconflictmarker = ('{node|short} ' +
301 '{ifeq(tags, "tip", "", "{tags} ")}' + 297 '{ifeq(tags, "tip", "", "{tags} ")}' +
302 '{if(bookmarks, "{bookmarks} ")}' + 298 '{if(bookmarks, "{bookmarks} ")}' +
303 '{ifeq(branch, "default", "", "{branch} ")}' + 299 '{ifeq(branch, "default", "", "{branch} ")}' +