comparison tests/test-simplemerge.py @ 10282:08a0f04b56bd

many, many trivial check-code fixups
author Matt Mackall <mpm@selenic.com>
date Mon, 25 Jan 2010 00:05:27 -0600
parents e75aab656f46
children e433002acb05
comparison
equal deleted inserted replaced
10281:e7d3b509af8b 10282:08a0f04b56bd
87 87
88 -- The Way of Lao-Tzu, tr. Wing-tsit Chan 88 -- The Way of Lao-Tzu, tr. Wing-tsit Chan
89 89
90 """) 90 """)
91 91
92 MERGED_RESULT = split_lines(""" The Way that can be told of is not the eternal Way; 92 MERGED_RESULT = split_lines("""\
93 The Way that can be told of is not the eternal Way;
93 The name that can be named is not the eternal name. 94 The name that can be named is not the eternal name.
94 The Nameless is the origin of Heaven and Earth; 95 The Nameless is the origin of Heaven and Earth;
95 The Named is the mother of all things. 96 The Named is the mother of all things.
96 Therefore let there always be non-being, 97 Therefore let there always be non-being,
97 so we may see their subtlety, 98 so we may see their subtlety,
123 124
124 self.assertEquals(list(m3.find_sync_regions()), 125 self.assertEquals(list(m3.find_sync_regions()),
125 [(0, 2, 126 [(0, 2,
126 0, 2, 127 0, 2,
127 0, 2), 128 0, 2),
128 (2,2, 2,2, 2,2)]) 129 (2, 2, 2, 2, 2, 2)])
129 130
130 self.assertEquals(list(m3.merge_regions()), 131 self.assertEquals(list(m3.merge_regions()),
131 [('unchanged', 0, 2)]) 132 [('unchanged', 0, 2)])
132 133
133 self.assertEquals(list(m3.merge_groups()), 134 self.assertEquals(list(m3.merge_groups()),
139 ['zz']) 140 ['zz'])
140 141
141 # todo: should use a sentinal at end as from get_matching_blocks 142 # todo: should use a sentinal at end as from get_matching_blocks
142 # to match without zz 143 # to match without zz
143 self.assertEquals(list(m3.find_sync_regions()), 144 self.assertEquals(list(m3.find_sync_regions()),
144 [(0,1, 2,3, 0,1), 145 [(0, 1, 2, 3, 0, 1),
145 (1,1, 3,3, 1,1),]) 146 (1, 1, 3, 3, 1, 1),])
146 147
147 self.assertEquals(list(m3.merge_regions()), 148 self.assertEquals(list(m3.merge_regions()),
148 [('a', 0, 2), 149 [('a', 0, 2),
149 ('unchanged', 0, 1)]) 150 ('unchanged', 0, 1)])
150 151
157 ['aaa', 'bbb'], 158 ['aaa', 'bbb'],
158 []) 159 [])
159 # todo: should use a sentinal at end as from get_matching_blocks 160 # todo: should use a sentinal at end as from get_matching_blocks
160 # to match without zz 161 # to match without zz
161 self.assertEquals(list(m3.find_sync_regions()), 162 self.assertEquals(list(m3.find_sync_regions()),
162 [(0,0, 2,2, 0,0)]) 163 [(0, 0, 2, 2, 0, 0)])
163 164
164 self.assertEquals(list(m3.merge_regions()), 165 self.assertEquals(list(m3.merge_regions()),
165 [('a', 0, 2)]) 166 [('a', 0, 2)])
166 167
167 self.assertEquals(list(m3.merge_lines()), 168 self.assertEquals(list(m3.merge_lines()),
175 176
176 self.assertEquals(m3.find_unconflicted(), 177 self.assertEquals(m3.find_unconflicted(),
177 [(0, 1), (1, 2)]) 178 [(0, 1), (1, 2)])
178 179
179 self.assertEquals(list(m3.find_sync_regions()), 180 self.assertEquals(list(m3.find_sync_regions()),
180 [(0,1, 0,1, 0,1), 181 [(0, 1, 0, 1, 0, 1),
181 (1,2, 2,3, 1,2), 182 (1, 2, 2, 3, 1, 2),
182 (2,2, 3,3, 2,2),]) 183 (2, 2, 3, 3, 2, 2),])
183 184
184 self.assertEquals(list(m3.merge_regions()), 185 self.assertEquals(list(m3.merge_regions()),
185 [('unchanged', 0, 1), 186 [('unchanged', 0, 1),
186 ('a', 1, 2), 187 ('a', 1, 2),
187 ('unchanged', 1, 2),]) 188 ('unchanged', 1, 2),])
251 252
252 self.assertEquals(m3.find_unconflicted(), 253 self.assertEquals(m3.find_unconflicted(),
253 [(0, 1), (1, 2)]) 254 [(0, 1), (1, 2)])
254 255
255 self.assertEquals(list(m3.find_sync_regions()), 256 self.assertEquals(list(m3.find_sync_regions()),
256 [(0,1, 0,1, 0,1), 257 [(0, 1, 0, 1, 0, 1),
257 (1,2, 2,3, 2,3), 258 (1, 2, 2, 3, 2, 3),
258 (2,2, 3,3, 3,3),]) 259 (2, 2, 3, 3, 3, 3),])
259 260
260 self.assertEquals(list(m3.merge_regions()), 261 self.assertEquals(list(m3.merge_regions()),
261 [('unchanged', 0,1), 262 [('unchanged', 0, 1),
262 ('conflict', 1,1, 1,2, 1,2), 263 ('conflict', 1, 1, 1, 2, 1, 2),
263 ('unchanged', 1,2)]) 264 ('unchanged', 1, 2)])
264 265
265 self.assertEquals(list(m3.merge_groups()), 266 self.assertEquals(list(m3.merge_groups()),
266 [('unchanged', ['aaa\n']), 267 [('unchanged', ['aaa\n']),
267 ('conflict', [], ['111\n'], ['222\n']), 268 ('conflict', [], ['111\n'], ['222\n']),
268 ('unchanged', ['bbb\n']), 269 ('unchanged', ['bbb\n']),
291 292
292 self.assertEquals(m3.find_unconflicted(), 293 self.assertEquals(m3.find_unconflicted(),
293 [(0, 1), (2, 3)]) 294 [(0, 1), (2, 3)])
294 295
295 self.assertEquals(list(m3.find_sync_regions()), 296 self.assertEquals(list(m3.find_sync_regions()),
296 [(0,1, 0,1, 0,1), 297 [(0, 1, 0, 1, 0, 1),
297 (2,3, 2,3, 2,3), 298 (2, 3, 2, 3, 2, 3),
298 (3,3, 3,3, 3,3),]) 299 (3, 3, 3, 3, 3, 3),])
299 300
300 def test_replace_multi(self): 301 def test_replace_multi(self):
301 """Replacement with regions of different size.""" 302 """Replacement with regions of different size."""
302 m3 = Merge3(['aaa', '000', '000', 'bbb'], 303 m3 = Merge3(['aaa', '000', '000', 'bbb'],
303 ['aaa', '111', '111', '111', 'bbb'], 304 ['aaa', '111', '111', '111', 'bbb'],
306 self.assertEquals(m3.find_unconflicted(), 307 self.assertEquals(m3.find_unconflicted(),
307 [(0, 1), (3, 4)]) 308 [(0, 1), (3, 4)])
308 309
309 310
310 self.assertEquals(list(m3.find_sync_regions()), 311 self.assertEquals(list(m3.find_sync_regions()),
311 [(0,1, 0,1, 0,1), 312 [(0, 1, 0, 1, 0, 1),
312 (3,4, 4,5, 5,6), 313 (3, 4, 4, 5, 5, 6),
313 (4,4, 5,5, 6,6),]) 314 (4, 4, 5, 5, 6, 6)])
314 315
315 def test_merge_poem(self): 316 def test_merge_poem(self):
316 """Test case from diff3 manual""" 317 """Test case from diff3 manual"""
317 m3 = Merge3(TZU, LAO, TAO) 318 m3 = Merge3(TZU, LAO, TAO)
318 ml = list(m3.merge_lines('LAO', 'TAO')) 319 ml = list(m3.merge_lines('LAO', 'TAO'))