1
# Copyright (C) 2004, 2005 by Canonical Ltd
1
# Copyright (C) 2004, 2005 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
5
5
# the Free Software Foundation; either version 2 of the License, or
6
6
# (at your option) any later version.
8
8
# This program is distributed in the hope that it will be useful,
9
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
11
# GNU General Public License for more details.
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
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
364
364
def test_binary(self):
365
365
self.assertRaises(BinaryFile, Merge3, ['\x00'], ['a'], ['b'])
367
def test_dos_text(self):
371
m3 = Merge3(base_text.splitlines(True), other_text.splitlines(True),
372
this_text.splitlines(True))
373
m_lines = m3.merge_lines('OTHER', 'THIS')
374
self.assertEqual('<<<<<<< OTHER\r\nc\r\n=======\r\nb\r\n'
375
'>>>>>>> THIS\r\n'.splitlines(True), list(m_lines))
377
def test_mac_text(self):
381
m3 = Merge3(base_text.splitlines(True), other_text.splitlines(True),
382
this_text.splitlines(True))
383
m_lines = m3.merge_lines('OTHER', 'THIS')
384
self.assertEqual('<<<<<<< OTHER\rc\r=======\rb\r'
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'