##// 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 mid_marker='=======',
92 mid_marker='=======',
93 end_marker='>>>>>>>',
93 end_marker='>>>>>>>',
94 base_marker=None,
94 base_marker=None,
95 localorother=None):
95 localorother=None,
96 minimize=False):
96 """Return merge in cvs-like form.
97 """Return merge in cvs-like form.
97 """
98 """
98 self.conflicts = False
99 self.conflicts = False
@@ -109,6 +110,8 b' class Merge3Text(object):'
109 if name_base and base_marker:
110 if name_base and base_marker:
110 base_marker = base_marker + ' ' + name_base
111 base_marker = base_marker + ' ' + name_base
111 merge_regions = self.merge_regions()
112 merge_regions = self.merge_regions()
113 if minimize:
114 merge_regions = self.minimize(merge_regions)
112 for t in merge_regions:
115 for t in merge_regions:
113 what = t[0]
116 what = t[0]
114 if what == 'unchanged':
117 if what == 'unchanged':
@@ -441,7 +444,10 b' def simplemerge(ui, local, base, other, '
441 out = sys.stdout
444 out = sys.stdout
442
445
443 m3 = Merge3Text(basetext, localtext, othertext)
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 if mode == 'union':
451 if mode == 'union':
446 extrakwargs['start_marker'] = None
452 extrakwargs['start_marker'] = None
447 extrakwargs['mid_marker'] = None
453 extrakwargs['mid_marker'] = None
@@ -449,6 +455,7 b' def simplemerge(ui, local, base, other, '
449 elif name_base is not None:
455 elif name_base is not None:
450 extrakwargs['base_marker'] = '|||||||'
456 extrakwargs['base_marker'] = '|||||||'
451 extrakwargs['name_base'] = name_base
457 extrakwargs['name_base'] = name_base
458 extrakwargs['minimize'] = False
452 for line in m3.merge_lines(name_a=name_a, name_b=name_b, **extrakwargs):
459 for line in m3.merge_lines(name_a=name_a, name_b=name_b, **extrakwargs):
453 out.write(line)
460 out.write(line)
454
461
@@ -46,16 +46,13 b''
46
46
47 $ cat a
47 $ cat a
48 Small Mathematical Series.
48 Small Mathematical Series.
49 <<<<<<< local: 618808747361 - test: branch2
50 1
49 1
51 2
50 2
52 3
51 3
52 <<<<<<< local: 618808747361 - test: branch2
53 6
53 6
54 8
54 8
55 =======
55 =======
56 1
57 2
58 3
59 4
56 4
60 5
57 5
61 >>>>>>> other: c0c68e4fe667 - test: branch1
58 >>>>>>> other: c0c68e4fe667 - test: branch1
@@ -79,16 +76,13 b' Verify custom conflict markers'
79
76
80 $ cat a
77 $ cat a
81 Small Mathematical Series.
78 Small Mathematical Series.
82 <<<<<<< local: test 2
83 1
79 1
84 2
80 2
85 3
81 3
82 <<<<<<< local: test 2
86 6
83 6
87 8
84 8
88 =======
85 =======
89 1
90 2
91 3
92 4
86 4
93 5
87 5
94 >>>>>>> other: test 1
88 >>>>>>> other: test 1
@@ -108,16 +102,13 b' Verify line splitting of custom conflict'
108
102
109 $ cat a
103 $ cat a
110 Small Mathematical Series.
104 Small Mathematical Series.
111 <<<<<<< local: test 2
112 1
105 1
113 2
106 2
114 3
107 3
108 <<<<<<< local: test 2
115 6
109 6
116 8
110 8
117 =======
111 =======
118 1
119 2
120 3
121 4
112 4
122 5
113 5
123 >>>>>>> other: test 1
114 >>>>>>> other: test 1
@@ -150,16 +141,13 b' Verify line trimming of custom conflict '
150
141
151 $ cat a
142 $ cat a
152 Small Mathematical Series.
143 Small Mathematical Series.
153 <<<<<<< local: 123456789012345678901234567890123456789012345678901234567890\xe3\x81\x82... (esc)
154 1
144 1
155 2
145 2
156 3
146 3
147 <<<<<<< local: 123456789012345678901234567890123456789012345678901234567890\xe3\x81\x82... (esc)
157 6
148 6
158 8
149 8
159 =======
150 =======
160 1
161 2
162 3
163 4
151 4
164 5
152 5
165 >>>>>>> other: branch1
153 >>>>>>> other: branch1
@@ -179,16 +167,13 b' Verify basic conflict markers'
179
167
180 $ cat a
168 $ cat a
181 Small Mathematical Series.
169 Small Mathematical Series.
182 <<<<<<< local
183 1
170 1
184 2
171 2
185 3
172 3
173 <<<<<<< local
186 6
174 6
187 8
175 8
188 =======
176 =======
189 1
190 2
191 3
192 4
177 4
193 5
178 5
194 >>>>>>> other
179 >>>>>>> other
@@ -148,11 +148,10 b' conflicts'
148 base
148 base
149 <<<<<<< conflict-local
149 <<<<<<< conflict-local
150 not other
150 not other
151 end
152 =======
151 =======
153 other
152 other
153 >>>>>>> conflict-other
154 end
154 end
155 >>>>>>> conflict-other
156 [1]
155 [1]
157
156
158 1 label
157 1 label
@@ -161,11 +160,10 b' 1 label'
161 base
160 base
162 <<<<<<< foo
161 <<<<<<< foo
163 not other
162 not other
164 end
165 =======
163 =======
166 other
164 other
165 >>>>>>> conflict-other
167 end
166 end
168 >>>>>>> conflict-other
169 [1]
167 [1]
170
168
171 2 labels
169 2 labels
@@ -174,11 +172,10 b' 2 labels'
174 base
172 base
175 <<<<<<< foo
173 <<<<<<< foo
176 not other
174 not other
177 end
178 =======
175 =======
179 other
176 other
177 >>>>>>> bar
180 end
178 end
181 >>>>>>> bar
182 [1]
179 [1]
183
180
184 3 labels
181 3 labels
@@ -305,3 +305,55 b' Check that the right ancestors is used w'
305 rebase completed
305 rebase completed
306 updating the branch cache
306 updating the branch cache
307 truncating cache/rbc-revs-v1 to 72
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