13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
18
from bzrlib.tests import TestCaseInTempDir, TestCase
29
29
TZU = split_lines(""" The Nameless is the origin of Heaven and Earth;
30
30
The named is the mother of all things.
32
32
Therefore let there always be non-being,
33
33
so we may see their subtlety,
34
34
And let there always be being,
59
59
The name that can be named is not the eternal name.
60
60
The Nameless is the origin of Heaven and Earth;
61
61
The named is the mother of all things.
63
63
Therefore let there always be non-being,
64
64
so we may see their subtlety,
65
65
And let there always be being,
357
357
this_text = ("a\n"*10+"b\n" * 10).splitlines(True)
358
358
other_text = ("a\n"*10+"c\n"+"b\n" * 8 + "c\n").splitlines(True)
359
359
m3 = Merge3(base_text, other_text, this_text)
360
m_lines = m3.merge_lines('OTHER', 'THIS', reprocess=True,
360
m_lines = m3.merge_lines('OTHER', 'THIS', reprocess=True,
361
361
base_marker='|||||||')
362
362
self.assertRaises(CantReprocessAndShowBase, list, m_lines)
383
383
m_lines = m3.merge_lines('OTHER', 'THIS')
384
384
self.assertEqual('<<<<<<< OTHER\rc\r=======\rb\r'
385
385
'>>>>>>> THIS\r'.splitlines(True), list(m_lines))
387
def test_merge3_cherrypick(self):
390
other_text = "a\nb\nc\n"
391
# When cherrypicking, lines in base are not part of the conflict
392
m3 = Merge3(base_text.splitlines(True), this_text.splitlines(True),
393
other_text.splitlines(True), is_cherrypick=True)
394
m_lines = m3.merge_lines()
395
self.assertEqualDiff('a\n<<<<<<<\n=======\nc\n>>>>>>>\n',
398
# This is not symmetric
399
m3 = Merge3(base_text.splitlines(True), other_text.splitlines(True),
400
this_text.splitlines(True), is_cherrypick=True)
401
m_lines = m3.merge_lines()
402
self.assertEqualDiff('a\n<<<<<<<\nb\nc\n=======\n>>>>>>>\n',
405
def test_merge3_cherrypick_w_mixed(self):
406
base_text = 'a\nb\nc\nd\ne\n'
407
this_text = 'a\nb\nq\n'
408
other_text = 'a\nb\nc\nd\nf\ne\ng\n'
409
# When cherrypicking, lines in base are not part of the conflict
410
m3 = Merge3(base_text.splitlines(True), this_text.splitlines(True),
411
other_text.splitlines(True), is_cherrypick=True)
412
m_lines = m3.merge_lines()
413
self.assertEqualDiff('a\n'