##// END OF EJS Templates
filemerge: use 'util.ellipsis' to trim custom conflict markers correctly...
FUJIWARA Katsunori -
r21865:78e56e70 default
parent child Browse files
Show More
@@ -290,12 +290,8 b' def _formatconflictmarker(repo, ctx, tem'
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} ")}' +
@@ -72,9 +72,42 b' Verify line splitting of custom conflict'
72 something
72 something
73 >>>>>>> other: test 1
73 >>>>>>> other: test 1
74
74
75 Verify line trimming of custom conflict marker using multi-byte characters
76
77 $ hg up -q --clean .
78 $ python <<EOF
79 > fp = open('logfile', 'w')
80 > fp.write('12345678901234567890123456789012345678901234567890' +
81 > '1234567890') # there are 5 more columns for 80 columns
82 >
83 > # 2 x 4 = 8 columns, but 3 x 4 = 12 bytes
84 > fp.write(u'\u3042\u3044\u3046\u3048'.encode('utf-8'))
85 >
86 > fp.close()
87 > EOF
88 $ hg add logfile
89 $ hg --encoding utf-8 commit --logfile logfile
90
91 $ cat >> .hg/hgrc <<EOF
92 > [ui]
93 > mergemarkertemplate={desc|firstline}
94 > EOF
95
96 $ hg -q --encoding utf-8 merge 1
97 warning: conflicts during merge.
98 merging a incomplete! (edit conflicts, then use 'hg resolve --mark')
99 [1]
100
101 $ cat a
102 <<<<<<< local: 123456789012345678901234567890123456789012345678901234567890\xe3\x81\x82... (esc)
103 something else
104 =======
105 something
106 >>>>>>> other: branch1
107
75 Verify basic conflict markers
108 Verify basic conflict markers
76
109
77 $ hg up -q --clean .
110 $ hg up -q --clean 2
78 $ printf "\n[ui]\nmergemarkers=basic\n" >> .hg/hgrc
111 $ printf "\n[ui]\nmergemarkers=basic\n" >> .hg/hgrc
79
112
80 $ hg merge 1
113 $ hg merge 1
General Comments 0
You need to be logged in to leave comments. Login now