##// END OF EJS Templates
merge: minimize conflicts when common base is not shown (issue4447)...
Ryan McElroy -
r28072:c3e9269d default
parent child Browse files
Show More
@@ -92,7 +92,8 b' class Merge3Text(object):'
92 92 mid_marker='=======',
93 93 end_marker='>>>>>>>',
94 94 base_marker=None,
95 localorother=None):
95 localorother=None,
96 minimize=False):
96 97 """Return merge in cvs-like form.
97 98 """
98 99 self.conflicts = False
@@ -109,6 +110,8 b' class Merge3Text(object):'
109 110 if name_base and base_marker:
110 111 base_marker = base_marker + ' ' + name_base
111 112 merge_regions = self.merge_regions()
113 if minimize:
114 merge_regions = self.minimize(merge_regions)
112 115 for t in merge_regions:
113 116 what = t[0]
114 117 if what == 'unchanged':
@@ -441,7 +444,10 b' def simplemerge(ui, local, base, other, '
441 444 out = sys.stdout
442 445
443 446 m3 = Merge3Text(basetext, localtext, othertext)
444 extrakwargs = {"localorother": opts.get("localorother", None)}
447 extrakwargs = {
448 "localorother": opts.get("localorother", None),
449 'minimize': True,
450 }
445 451 if mode == 'union':
446 452 extrakwargs['start_marker'] = None
447 453 extrakwargs['mid_marker'] = None
@@ -449,6 +455,7 b' def simplemerge(ui, local, base, other, '
449 455 elif name_base is not None:
450 456 extrakwargs['base_marker'] = '|||||||'
451 457 extrakwargs['name_base'] = name_base
458 extrakwargs['minimize'] = False
452 459 for line in m3.merge_lines(name_a=name_a, name_b=name_b, **extrakwargs):
453 460 out.write(line)
454 461
@@ -46,16 +46,13 b''
46 46
47 47 $ cat a
48 48 Small Mathematical Series.
49 <<<<<<< local: 618808747361 - test: branch2
50 49 1
51 50 2
52 51 3
52 <<<<<<< local: 618808747361 - test: branch2
53 53 6
54 54 8
55 55 =======
56 1
57 2
58 3
59 56 4
60 57 5
61 58 >>>>>>> other: c0c68e4fe667 - test: branch1
@@ -79,16 +76,13 b' Verify custom conflict markers'
79 76
80 77 $ cat a
81 78 Small Mathematical Series.
82 <<<<<<< local: test 2
83 79 1
84 80 2
85 81 3
82 <<<<<<< local: test 2
86 83 6
87 84 8
88 85 =======
89 1
90 2
91 3
92 86 4
93 87 5
94 88 >>>>>>> other: test 1
@@ -108,16 +102,13 b' Verify line splitting of custom conflict'
108 102
109 103 $ cat a
110 104 Small Mathematical Series.
111 <<<<<<< local: test 2
112 105 1
113 106 2
114 107 3
108 <<<<<<< local: test 2
115 109 6
116 110 8
117 111 =======
118 1
119 2
120 3
121 112 4
122 113 5
123 114 >>>>>>> other: test 1
@@ -150,16 +141,13 b' Verify line trimming of custom conflict '
150 141
151 142 $ cat a
152 143 Small Mathematical Series.
153 <<<<<<< local: 123456789012345678901234567890123456789012345678901234567890\xe3\x81\x82... (esc)
154 144 1
155 145 2
156 146 3
147 <<<<<<< local: 123456789012345678901234567890123456789012345678901234567890\xe3\x81\x82... (esc)
157 148 6
158 149 8
159 150 =======
160 1
161 2
162 3
163 151 4
164 152 5
165 153 >>>>>>> other: branch1
@@ -179,16 +167,13 b' Verify basic conflict markers'
179 167
180 168 $ cat a
181 169 Small Mathematical Series.
182 <<<<<<< local
183 170 1
184 171 2
185 172 3
173 <<<<<<< local
186 174 6
187 175 8
188 176 =======
189 1
190 2
191 3
192 177 4
193 178 5
194 179 >>>>>>> other
@@ -148,11 +148,10 b' conflicts'
148 148 base
149 149 <<<<<<< conflict-local
150 150 not other
151 end
152 151 =======
153 152 other
153 >>>>>>> conflict-other
154 154 end
155 >>>>>>> conflict-other
156 155 [1]
157 156
158 157 1 label
@@ -161,11 +160,10 b' 1 label'
161 160 base
162 161 <<<<<<< foo
163 162 not other
164 end
165 163 =======
166 164 other
165 >>>>>>> conflict-other
167 166 end
168 >>>>>>> conflict-other
169 167 [1]
170 168
171 169 2 labels
@@ -174,11 +172,10 b' 2 labels'
174 172 base
175 173 <<<<<<< foo
176 174 not other
177 end
178 175 =======
179 176 other
177 >>>>>>> bar
180 178 end
181 >>>>>>> bar
182 179 [1]
183 180
184 181 3 labels
@@ -305,3 +305,55 b' Check that the right ancestors is used w'
305 305 rebase completed
306 306 updating the branch cache
307 307 truncating cache/rbc-revs-v1 to 72
308
309 Test minimization of merge conflicts
310 $ hg up -q null
311 $ echo a > a
312 $ hg add a
313 $ hg commit -q -m 'a'
314 $ echo b >> a
315 $ hg commit -q -m 'ab'
316 $ hg bookmark ab
317 $ hg up -q '.^'
318 $ echo b >> a
319 $ echo c >> a
320 $ hg commit -q -m 'abc'
321 $ hg rebase -s 7bc217434fc1 -d ab --keep
322 rebasing 13:7bc217434fc1 "abc" (tip)
323 merging a
324 warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
325 unresolved conflicts (see hg resolve, then hg rebase --continue)
326 [1]
327 $ hg diff
328 diff -r 328e4ab1f7cc a
329 --- a/a Thu Jan 01 00:00:00 1970 +0000
330 +++ b/a * (glob)
331 @@ -1,2 +1,6 @@
332 a
333 b
334 +<<<<<<< dest: 328e4ab1f7cc ab - test: ab
335 +=======
336 +c
337 +>>>>>>> source: 7bc217434fc1 - test: abc
338 $ hg rebase --abort
339 rebase aborted
340 $ hg up -q -C 7bc217434fc1
341 $ hg rebase -s . -d ab --keep -t internal:merge3
342 rebasing 13:7bc217434fc1 "abc" (tip)
343 merging a
344 warning: conflicts while merging a! (edit, then use 'hg resolve --mark')
345 unresolved conflicts (see hg resolve, then hg rebase --continue)
346 [1]
347 $ hg diff
348 diff -r 328e4ab1f7cc a
349 --- a/a Thu Jan 01 00:00:00 1970 +0000
350 +++ b/a * (glob)
351 @@ -1,2 +1,8 @@
352 a
353 +<<<<<<< dest: 328e4ab1f7cc ab - test: ab
354 b
355 +||||||| base
356 +=======
357 +b
358 +c
359 +>>>>>>> source: 7bc217434fc1 - test: abc
General Comments 0
You need to be logged in to leave comments. Login now