# HG changeset patch # User Martin von Zweigbergk # Date 2022-01-12 00:54:42 # Node ID 2dbee604a4f00d62df843885735b988d5620c799 # Parent c6649c53073f0ce3918779a3fed87dd63c7438e9 simplemerge: clarify names of functions that render conflict markers Differential Revision: https://phab.mercurial-scm.org/D11975 diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py --- a/mercurial/debugcommands.py +++ b/mercurial/debugcommands.py @@ -272,7 +272,9 @@ def debugbuilddag( 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") diff --git a/mercurial/simplemerge.py b/mercurial/simplemerge.py --- a/mercurial/simplemerge.py +++ b/mercurial/simplemerge.py @@ -341,7 +341,7 @@ def _picklabels(defaults, overrides): return result -def merge_lines( +def render_markers( m3, name_a=None, name_b=None, @@ -390,7 +390,7 @@ def merge_lines( 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 @@ def simplemerge(ui, localctx, basectx, o [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 @@ def simplemerge(ui, localctx, basectx, o 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 ) diff --git a/tests/test-simplemerge.py b/tests/test-simplemerge.py --- a/tests/test-simplemerge.py +++ b/tests/test-simplemerge.py @@ -179,7 +179,9 @@ class TestMerge3(TestCase): 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 @@ class TestMerge3(TestCase): ) 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 @@ class TestMerge3(TestCase): ) 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 @@ class TestMerge3(TestCase): ) 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 @@ class TestMerge3(TestCase): [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 @@ class TestMerge3(TestCase): [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 @@ class TestMerge3(TestCase): ], ) - ml, conflicts = simplemerge.merge_lines( + ml, conflicts = simplemerge.render_markers( m3, name_a=b'a', name_b=b'b', @@ -347,7 +349,7 @@ bbb 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 @@ bbb 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 @@ bbb 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),