diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py --- a/mercurial/filemerge.py +++ b/mercurial/filemerge.py @@ -290,12 +290,8 @@ def _formatconflictmarker(repo, ctx, tem 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} ")}' + diff --git a/tests/test-conflict.t b/tests/test-conflict.t --- a/tests/test-conflict.t +++ b/tests/test-conflict.t @@ -72,9 +72,42 @@ Verify line splitting of custom conflict something >>>>>>> other: test 1 +Verify line trimming of custom conflict marker using multi-byte characters + + $ hg up -q --clean . + $ python < fp = open('logfile', 'w') + > fp.write('12345678901234567890123456789012345678901234567890' + + > '1234567890') # there are 5 more columns for 80 columns + > + > # 2 x 4 = 8 columns, but 3 x 4 = 12 bytes + > fp.write(u'\u3042\u3044\u3046\u3048'.encode('utf-8')) + > + > fp.close() + > EOF + $ hg add logfile + $ hg --encoding utf-8 commit --logfile logfile + + $ cat >> .hg/hgrc < [ui] + > mergemarkertemplate={desc|firstline} + > EOF + + $ hg -q --encoding utf-8 merge 1 + warning: conflicts during merge. + merging a incomplete! (edit conflicts, then use 'hg resolve --mark') + [1] + + $ cat a + <<<<<<< local: 123456789012345678901234567890123456789012345678901234567890\xe3\x81\x82... (esc) + something else + ======= + something + >>>>>>> other: branch1 + Verify basic conflict markers - $ hg up -q --clean . + $ hg up -q --clean 2 $ printf "\n[ui]\nmergemarkers=basic\n" >> .hg/hgrc $ hg merge 1