1
# Copyright (C) 2004, 2005 by Canonical Ltd
3
# This program is free software; you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation; either version 2 of the License, or
6
# (at your option) any later version.
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
# GNU General Public License for more details.
13
# You should have received a copy of the GNU General Public License
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
18
from bzrlib.selftest import InTempDir, TestBase
19
from bzrlib.merge3 import Merge3
21
class NoChanges(TestBase):
22
"""No conflicts because nothing changed"""
24
m3 = Merge3(['aaa', 'bbb'],
28
self.assertEquals(m3.find_unconflicted(),
31
self.assertEquals(list(m3.find_sync_regions()),
32
[((0, 2), (0, 2), (0, 2))])
36
class NoConflicts(TestBase):
37
"""No conflicts because only one side changed"""
39
m3 = Merge3(['aaa', 'bbb'],
40
['aaa', '111', 'bbb'],
43
self.assertEquals(m3.find_unconflicted(),
47
self.assertEquals(list(m3.find_sync_regions()),
48
[((0, 1), (0, 1), (0, 1)),
49
((1, 2), (2, 3), (1, 2))])
52
class InsertClash(TestBase):
53
"""Both try to insert lines in the same place."""
55
m3 = Merge3(['aaa', 'bbb'],
56
['aaa', '111', 'bbb'],
57
['aaa', '222', 'bbb'])
59
self.assertEquals(m3.find_unconflicted(),
62
self.assertEquals(list(m3.find_sync_regions()),
63
[((0, 1), (0, 1), (0, 1)),
64
((1, 2), (2, 3), (2, 3))])
68
class ReplaceClash(TestBase):
69
"""Both try to insert lines in the same place."""
71
m3 = Merge3(['aaa', '000', 'bbb'],
72
['aaa', '111', 'bbb'],
73
['aaa', '222', 'bbb'])
75
self.assertEquals(m3.find_unconflicted(),
78
self.assertEquals(list(m3.find_sync_regions()),
79
[((0, 1), (0, 1), (0, 1)),
80
((2, 3), (2, 3), (2, 3))])
84
class ReplaceMulti(TestBase):
85
"""Replacement with regions of different size."""
87
m3 = Merge3(['aaa', '000', '000', 'bbb'],
88
['aaa', '111', '111', '111', 'bbb'],
89
['aaa', '222', '222', '222', '222', 'bbb'])
91
self.assertEquals(m3.find_unconflicted(),
95
self.assertEquals(list(m3.find_sync_regions()),
96
[((0, 1), (0, 1), (0, 1)),
97
((3, 4), (4, 5), (5, 6))])