##// END OF EJS Templates
simplemerge: clarify names of functions that render conflict markers...
Martin von Zweigbergk -
r49407:2dbee604 default
parent child Browse files
Show More
@@ -272,7 +272,9 b' def debugbuilddag('
272 x[fn].data() for x in (pa, p1, p2)
272 x[fn].data() for x in (pa, p1, p2)
273 ]
273 ]
274 m3 = simplemerge.Merge3Text(base, local, other)
274 m3 = simplemerge.Merge3Text(base, local, other)
275 ml = [l.strip() for l in simplemerge.merge_lines(m3)[0]]
275 ml = [
276 l.strip() for l in simplemerge.render_markers(m3)[0]
277 ]
276 ml.append(b"")
278 ml.append(b"")
277 elif at > 0:
279 elif at > 0:
278 ml = p1[fn].data().split(b"\n")
280 ml = p1[fn].data().split(b"\n")
@@ -341,7 +341,7 b' def _picklabels(defaults, overrides):'
341 return result
341 return result
342
342
343
343
344 def merge_lines(
344 def render_markers(
345 m3,
345 m3,
346 name_a=None,
346 name_a=None,
347 name_b=None,
347 name_b=None,
@@ -390,7 +390,7 b' def merge_lines('
390 return lines, conflicts
390 return lines, conflicts
391
391
392
392
393 def _mergediff(m3, name_a, name_b, name_base):
393 def render_mergediff(m3, name_a, name_b, name_base):
394 lines = []
394 lines = []
395 conflicts = False
395 conflicts = False
396 for what, group_lines in m3.merge_groups():
396 for what, group_lines in m3.merge_groups():
@@ -500,7 +500,7 b' def simplemerge(ui, localctx, basectx, o'
500 [localctx.path(), otherctx.path(), None], opts.get('label', [])
500 [localctx.path(), otherctx.path(), None], opts.get('label', [])
501 )
501 )
502 if mode == b'mergediff':
502 if mode == b'mergediff':
503 lines, conflicts = _mergediff(m3, name_a, name_b, name_base)
503 lines, conflicts = render_mergediff(m3, name_a, name_b, name_base)
504 else:
504 else:
505 extrakwargs = {
505 extrakwargs = {
506 'minimize': True,
506 'minimize': True,
@@ -509,7 +509,7 b' def simplemerge(ui, localctx, basectx, o'
509 extrakwargs['base_marker'] = b'|||||||'
509 extrakwargs['base_marker'] = b'|||||||'
510 extrakwargs['name_base'] = name_base
510 extrakwargs['name_base'] = name_base
511 extrakwargs['minimize'] = False
511 extrakwargs['minimize'] = False
512 lines, conflicts = merge_lines(
512 lines, conflicts = render_markers(
513 m3, name_a=name_a, name_b=name_b, **extrakwargs
513 m3, name_a=name_a, name_b=name_b, **extrakwargs
514 )
514 )
515
515
@@ -179,7 +179,9 b' class TestMerge3(TestCase):'
179
179
180 self.assertEqual(list(m3.merge_regions()), [(b'a', 0, 2)])
180 self.assertEqual(list(m3.merge_regions()), [(b'a', 0, 2)])
181
181
182 self.assertEqual(simplemerge.merge_lines(m3), ([b'aaa', b'bbb'], False))
182 self.assertEqual(
183 simplemerge.render_markers(m3), ([b'aaa', b'bbb'], False)
184 )
183
185
184 def test_no_conflicts(self):
186 def test_no_conflicts(self):
185 """No conflicts because only one side changed"""
187 """No conflicts because only one side changed"""
@@ -205,7 +207,7 b' class TestMerge3(TestCase):'
205 )
207 )
206
208
207 self.assertEqual(
209 self.assertEqual(
208 b''.join(simplemerge.merge_lines(m3)[0]), b'aaa\nbbb\n222\n'
210 b''.join(simplemerge.render_markers(m3)[0]), b'aaa\nbbb\n222\n'
209 )
211 )
210
212
211 def test_append_b(self):
213 def test_append_b(self):
@@ -216,7 +218,7 b' class TestMerge3(TestCase):'
216 )
218 )
217
219
218 self.assertEqual(
220 self.assertEqual(
219 b''.join(simplemerge.merge_lines(m3)[0]), b'aaa\nbbb\n222\n'
221 b''.join(simplemerge.render_markers(m3)[0]), b'aaa\nbbb\n222\n'
220 )
222 )
221
223
222 def test_append_agreement(self):
224 def test_append_agreement(self):
@@ -227,7 +229,7 b' class TestMerge3(TestCase):'
227 )
229 )
228
230
229 self.assertEqual(
231 self.assertEqual(
230 b''.join(simplemerge.merge_lines(m3)[0]), b'aaa\nbbb\n222\n'
232 b''.join(simplemerge.render_markers(m3)[0]), b'aaa\nbbb\n222\n'
231 )
233 )
232
234
233 def test_append_clash(self):
235 def test_append_clash(self):
@@ -237,7 +239,7 b' class TestMerge3(TestCase):'
237 [b'aaa\n', b'bbb\n', b'333\n'],
239 [b'aaa\n', b'bbb\n', b'333\n'],
238 )
240 )
239
241
240 ml, conflicts = simplemerge.merge_lines(
242 ml, conflicts = simplemerge.render_markers(
241 m3,
243 m3,
242 name_a=b'a',
244 name_a=b'a',
243 name_b=b'b',
245 name_b=b'b',
@@ -257,7 +259,7 b' class TestMerge3(TestCase):'
257 [b'aaa\n', b'222\n', b'bbb\n'],
259 [b'aaa\n', b'222\n', b'bbb\n'],
258 )
260 )
259
261
260 ml, conflicts = simplemerge.merge_lines(
262 ml, conflicts = simplemerge.render_markers(
261 m3,
263 m3,
262 name_a=b'a',
264 name_a=b'a',
263 name_b=b'b',
265 name_b=b'b',
@@ -298,7 +300,7 b' class TestMerge3(TestCase):'
298 ],
300 ],
299 )
301 )
300
302
301 ml, conflicts = simplemerge.merge_lines(
303 ml, conflicts = simplemerge.render_markers(
302 m3,
304 m3,
303 name_a=b'a',
305 name_a=b'a',
304 name_b=b'b',
306 name_b=b'b',
@@ -347,7 +349,7 b' bbb'
347 def test_merge_poem(self):
349 def test_merge_poem(self):
348 """Test case from diff3 manual"""
350 """Test case from diff3 manual"""
349 m3 = Merge3(TZU, LAO, TAO)
351 m3 = Merge3(TZU, LAO, TAO)
350 ml, conflicts = simplemerge.merge_lines(m3, b'LAO', b'TAO')
352 ml, conflicts = simplemerge.render_markers(m3, b'LAO', b'TAO')
351 self.log(b'merge result:')
353 self.log(b'merge result:')
352 self.log(b''.join(ml))
354 self.log(b''.join(ml))
353 self.assertEqual(ml, MERGED_RESULT)
355 self.assertEqual(ml, MERGED_RESULT)
@@ -365,7 +367,7 b' bbb'
365 other_text.splitlines(True),
367 other_text.splitlines(True),
366 this_text.splitlines(True),
368 this_text.splitlines(True),
367 )
369 )
368 m_lines, conflicts = simplemerge.merge_lines(m3, b'OTHER', b'THIS')
370 m_lines, conflicts = simplemerge.render_markers(m3, b'OTHER', b'THIS')
369 self.assertEqual(
371 self.assertEqual(
370 b'<<<<<<< OTHER\r\nc\r\n=======\r\nb\r\n'
372 b'<<<<<<< OTHER\r\nc\r\n=======\r\nb\r\n'
371 b'>>>>>>> THIS\r\n'.splitlines(True),
373 b'>>>>>>> THIS\r\n'.splitlines(True),
@@ -381,7 +383,7 b' bbb'
381 other_text.splitlines(True),
383 other_text.splitlines(True),
382 this_text.splitlines(True),
384 this_text.splitlines(True),
383 )
385 )
384 m_lines, conflicts = simplemerge.merge_lines(m3, b'OTHER', b'THIS')
386 m_lines, conflicts = simplemerge.render_markers(m3, b'OTHER', b'THIS')
385 self.assertEqual(
387 self.assertEqual(
386 b'<<<<<<< OTHER\rc\r=======\rb\r'
388 b'<<<<<<< OTHER\rc\r=======\rb\r'
387 b'>>>>>>> THIS\r'.splitlines(True),
389 b'>>>>>>> THIS\r'.splitlines(True),
General Comments 0
You need to be logged in to leave comments. Login now