Mercurial > hg
diff tests/test-simplemerge.py @ 48557:c6649c53073f
simplemerge: make merge_lines() a free function
IMO, the rendering of a conflict as text with merge markers should be
separate from the code for resolving conflicts. The latter is what
`Merge3Text` is mostly about already.
Differential Revision: https://phab.mercurial-scm.org/D11974
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Fri, 07 Jan 2022 22:16:22 -0800 |
parents | ce8c82a5cd65 |
children | 2dbee604a4f0 |
line wrap: on
line diff
--- a/tests/test-simplemerge.py Fri Jan 07 18:42:31 2022 -0800 +++ b/tests/test-simplemerge.py Fri Jan 07 22:16:22 2022 -0800 @@ -179,7 +179,7 @@ self.assertEqual(list(m3.merge_regions()), [(b'a', 0, 2)]) - self.assertEqual(m3.merge_lines(), ([b'aaa', b'bbb'], False)) + self.assertEqual(simplemerge.merge_lines(m3), ([b'aaa', b'bbb'], False)) def test_no_conflicts(self): """No conflicts because only one side changed""" @@ -204,7 +204,9 @@ [b'aaa\n', b'bbb\n'], ) - self.assertEqual(b''.join(m3.merge_lines()[0]), b'aaa\nbbb\n222\n') + self.assertEqual( + b''.join(simplemerge.merge_lines(m3)[0]), b'aaa\nbbb\n222\n' + ) def test_append_b(self): m3 = Merge3( @@ -213,7 +215,9 @@ [b'aaa\n', b'bbb\n', b'222\n'], ) - self.assertEqual(b''.join(m3.merge_lines()[0]), b'aaa\nbbb\n222\n') + self.assertEqual( + b''.join(simplemerge.merge_lines(m3)[0]), b'aaa\nbbb\n222\n' + ) def test_append_agreement(self): m3 = Merge3( @@ -222,7 +226,9 @@ [b'aaa\n', b'bbb\n', b'222\n'], ) - self.assertEqual(b''.join(m3.merge_lines()[0]), b'aaa\nbbb\n222\n') + self.assertEqual( + b''.join(simplemerge.merge_lines(m3)[0]), b'aaa\nbbb\n222\n' + ) def test_append_clash(self): m3 = Merge3( @@ -231,7 +237,8 @@ [b'aaa\n', b'bbb\n', b'333\n'], ) - ml, conflicts = m3.merge_lines( + ml, conflicts = simplemerge.merge_lines( + m3, name_a=b'a', name_b=b'b', start_marker=b'<<', @@ -250,7 +257,8 @@ [b'aaa\n', b'222\n', b'bbb\n'], ) - ml, conflicts = m3.merge_lines( + ml, conflicts = simplemerge.merge_lines( + m3, name_a=b'a', name_b=b'b', start_marker=b'<<', @@ -290,7 +298,8 @@ ], ) - ml, conflicts = m3.merge_lines( + ml, conflicts = simplemerge.merge_lines( + m3, name_a=b'a', name_b=b'b', start_marker=b'<<', @@ -338,7 +347,7 @@ def test_merge_poem(self): """Test case from diff3 manual""" m3 = Merge3(TZU, LAO, TAO) - ml, conflicts = m3.merge_lines(b'LAO', b'TAO') + ml, conflicts = simplemerge.merge_lines(m3, b'LAO', b'TAO') self.log(b'merge result:') self.log(b''.join(ml)) self.assertEqual(ml, MERGED_RESULT) @@ -356,7 +365,7 @@ other_text.splitlines(True), this_text.splitlines(True), ) - m_lines, conflicts = m3.merge_lines(b'OTHER', b'THIS') + m_lines, conflicts = simplemerge.merge_lines(m3, b'OTHER', b'THIS') self.assertEqual( b'<<<<<<< OTHER\r\nc\r\n=======\r\nb\r\n' b'>>>>>>> THIS\r\n'.splitlines(True), @@ -372,7 +381,7 @@ other_text.splitlines(True), this_text.splitlines(True), ) - m_lines, conflicts = m3.merge_lines(b'OTHER', b'THIS') + m_lines, conflicts = simplemerge.merge_lines(m3, b'OTHER', b'THIS') self.assertEqual( b'<<<<<<< OTHER\rc\r=======\rb\r' b'>>>>>>> THIS\r'.splitlines(True),