Mercurial > hg
diff tests/test-simplemerge.py @ 48556:ce8c82a5cd65
simplemerge: convert `merge_lines()` away from generator
We always consume all the lines and put them in a list anyway. By
making the function not a generator, we can later make it return an
additional value (to indicate if there were conflicts).
Differential Revision: https://phab.mercurial-scm.org/D11973
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Fri, 07 Jan 2022 18:42:31 -0800 |
parents | 374bf34c9ffd |
children | c6649c53073f |
line wrap: on
line diff
--- a/tests/test-simplemerge.py Tue Dec 14 13:12:56 2021 -0800 +++ b/tests/test-simplemerge.py Fri Jan 07 18:42:31 2022 -0800 @@ -179,7 +179,7 @@ self.assertEqual(list(m3.merge_regions()), [(b'a', 0, 2)]) - self.assertEqual(list(m3.merge_lines()), [b'aaa', b'bbb']) + self.assertEqual(m3.merge_lines(), ([b'aaa', b'bbb'], False)) def test_no_conflicts(self): """No conflicts because only one side changed""" @@ -204,7 +204,7 @@ [b'aaa\n', b'bbb\n'], ) - self.assertEqual(b''.join(m3.merge_lines()), b'aaa\nbbb\n222\n') + self.assertEqual(b''.join(m3.merge_lines()[0]), b'aaa\nbbb\n222\n') def test_append_b(self): m3 = Merge3( @@ -213,7 +213,7 @@ [b'aaa\n', b'bbb\n', b'222\n'], ) - self.assertEqual(b''.join(m3.merge_lines()), b'aaa\nbbb\n222\n') + self.assertEqual(b''.join(m3.merge_lines()[0]), b'aaa\nbbb\n222\n') def test_append_agreement(self): m3 = Merge3( @@ -222,7 +222,7 @@ [b'aaa\n', b'bbb\n', b'222\n'], ) - self.assertEqual(b''.join(m3.merge_lines()), b'aaa\nbbb\n222\n') + self.assertEqual(b''.join(m3.merge_lines()[0]), b'aaa\nbbb\n222\n') def test_append_clash(self): m3 = Merge3( @@ -231,7 +231,7 @@ [b'aaa\n', b'bbb\n', b'333\n'], ) - ml = m3.merge_lines( + ml, conflicts = m3.merge_lines( name_a=b'a', name_b=b'b', start_marker=b'<<', @@ -250,7 +250,7 @@ [b'aaa\n', b'222\n', b'bbb\n'], ) - ml = m3.merge_lines( + ml, conflicts = m3.merge_lines( name_a=b'a', name_b=b'b', start_marker=b'<<', @@ -290,7 +290,7 @@ ], ) - ml = m3.merge_lines( + ml, conflicts = m3.merge_lines( name_a=b'a', name_b=b'b', start_marker=b'<<', @@ -338,7 +338,7 @@ def test_merge_poem(self): """Test case from diff3 manual""" m3 = Merge3(TZU, LAO, TAO) - ml = list(m3.merge_lines(b'LAO', b'TAO')) + ml, conflicts = m3.merge_lines(b'LAO', b'TAO') self.log(b'merge result:') self.log(b''.join(ml)) self.assertEqual(ml, MERGED_RESULT) @@ -356,11 +356,11 @@ other_text.splitlines(True), this_text.splitlines(True), ) - m_lines = m3.merge_lines(b'OTHER', b'THIS') + m_lines, conflicts = m3.merge_lines(b'OTHER', b'THIS') self.assertEqual( b'<<<<<<< OTHER\r\nc\r\n=======\r\nb\r\n' b'>>>>>>> THIS\r\n'.splitlines(True), - list(m_lines), + m_lines, ) def test_mac_text(self): @@ -372,11 +372,11 @@ other_text.splitlines(True), this_text.splitlines(True), ) - m_lines = m3.merge_lines(b'OTHER', b'THIS') + m_lines, conflicts = m3.merge_lines(b'OTHER', b'THIS') self.assertEqual( b'<<<<<<< OTHER\rc\r=======\rb\r' b'>>>>>>> THIS\r'.splitlines(True), - list(m_lines), + m_lines, )