simplemerge: clarify names of functions that render conflict markers
Differential Revision: https://phab.mercurial-scm.org/D11975
--- a/mercurial/debugcommands.py Fri Jan 07 22:16:22 2022 -0800
+++ b/mercurial/debugcommands.py Tue Jan 11 16:54:42 2022 -0800
@@ -272,7 +272,9 @@
x[fn].data() for x in (pa, p1, p2)
]
m3 = simplemerge.Merge3Text(base, local, other)
- ml = [l.strip() for l in simplemerge.merge_lines(m3)[0]]
+ ml = [
+ l.strip() for l in simplemerge.render_markers(m3)[0]
+ ]
ml.append(b"")
elif at > 0:
ml = p1[fn].data().split(b"\n")
--- a/mercurial/simplemerge.py Fri Jan 07 22:16:22 2022 -0800
+++ b/mercurial/simplemerge.py Tue Jan 11 16:54:42 2022 -0800
@@ -341,7 +341,7 @@
return result
-def merge_lines(
+def render_markers(
m3,
name_a=None,
name_b=None,
@@ -390,7 +390,7 @@
return lines, conflicts
-def _mergediff(m3, name_a, name_b, name_base):
+def render_mergediff(m3, name_a, name_b, name_base):
lines = []
conflicts = False
for what, group_lines in m3.merge_groups():
@@ -500,7 +500,7 @@
[localctx.path(), otherctx.path(), None], opts.get('label', [])
)
if mode == b'mergediff':
- lines, conflicts = _mergediff(m3, name_a, name_b, name_base)
+ lines, conflicts = render_mergediff(m3, name_a, name_b, name_base)
else:
extrakwargs = {
'minimize': True,
@@ -509,7 +509,7 @@
extrakwargs['base_marker'] = b'|||||||'
extrakwargs['name_base'] = name_base
extrakwargs['minimize'] = False
- lines, conflicts = merge_lines(
+ lines, conflicts = render_markers(
m3, name_a=name_a, name_b=name_b, **extrakwargs
)
--- a/tests/test-simplemerge.py Fri Jan 07 22:16:22 2022 -0800
+++ b/tests/test-simplemerge.py Tue Jan 11 16:54:42 2022 -0800
@@ -179,7 +179,9 @@
self.assertEqual(list(m3.merge_regions()), [(b'a', 0, 2)])
- self.assertEqual(simplemerge.merge_lines(m3), ([b'aaa', b'bbb'], False))
+ self.assertEqual(
+ simplemerge.render_markers(m3), ([b'aaa', b'bbb'], False)
+ )
def test_no_conflicts(self):
"""No conflicts because only one side changed"""
@@ -205,7 +207,7 @@
)
self.assertEqual(
- b''.join(simplemerge.merge_lines(m3)[0]), b'aaa\nbbb\n222\n'
+ b''.join(simplemerge.render_markers(m3)[0]), b'aaa\nbbb\n222\n'
)
def test_append_b(self):
@@ -216,7 +218,7 @@
)
self.assertEqual(
- b''.join(simplemerge.merge_lines(m3)[0]), b'aaa\nbbb\n222\n'
+ b''.join(simplemerge.render_markers(m3)[0]), b'aaa\nbbb\n222\n'
)
def test_append_agreement(self):
@@ -227,7 +229,7 @@
)
self.assertEqual(
- b''.join(simplemerge.merge_lines(m3)[0]), b'aaa\nbbb\n222\n'
+ b''.join(simplemerge.render_markers(m3)[0]), b'aaa\nbbb\n222\n'
)
def test_append_clash(self):
@@ -237,7 +239,7 @@
[b'aaa\n', b'bbb\n', b'333\n'],
)
- ml, conflicts = simplemerge.merge_lines(
+ ml, conflicts = simplemerge.render_markers(
m3,
name_a=b'a',
name_b=b'b',
@@ -257,7 +259,7 @@
[b'aaa\n', b'222\n', b'bbb\n'],
)
- ml, conflicts = simplemerge.merge_lines(
+ ml, conflicts = simplemerge.render_markers(
m3,
name_a=b'a',
name_b=b'b',
@@ -298,7 +300,7 @@
],
)
- ml, conflicts = simplemerge.merge_lines(
+ ml, conflicts = simplemerge.render_markers(
m3,
name_a=b'a',
name_b=b'b',
@@ -347,7 +349,7 @@
def test_merge_poem(self):
"""Test case from diff3 manual"""
m3 = Merge3(TZU, LAO, TAO)
- ml, conflicts = simplemerge.merge_lines(m3, b'LAO', b'TAO')
+ ml, conflicts = simplemerge.render_markers(m3, b'LAO', b'TAO')
self.log(b'merge result:')
self.log(b''.join(ml))
self.assertEqual(ml, MERGED_RESULT)
@@ -365,7 +367,7 @@
other_text.splitlines(True),
this_text.splitlines(True),
)
- m_lines, conflicts = simplemerge.merge_lines(m3, b'OTHER', b'THIS')
+ m_lines, conflicts = simplemerge.render_markers(m3, b'OTHER', b'THIS')
self.assertEqual(
b'<<<<<<< OTHER\r\nc\r\n=======\r\nb\r\n'
b'>>>>>>> THIS\r\n'.splitlines(True),
@@ -381,7 +383,7 @@
other_text.splitlines(True),
this_text.splitlines(True),
)
- m_lines, conflicts = simplemerge.merge_lines(m3, b'OTHER', b'THIS')
+ m_lines, conflicts = simplemerge.render_markers(m3, b'OTHER', b'THIS')
self.assertEqual(
b'<<<<<<< OTHER\rc\r=======\rb\r'
b'>>>>>>> THIS\r'.splitlines(True),