Mercurial > hg-stable
comparison tests/test-simplemerge.py @ 23048:ee5f834077be stable
merge default into stable for 3.2 freeze
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sat, 18 Oct 2014 18:04:31 -0500 |
parents | f18830651811 |
children | 56b2bcea2529 |
comparison
equal
deleted
inserted
replaced
22843:b6531d806de8 | 23048:ee5f834077be |
---|---|
318 ml = list(m3.merge_lines('LAO', 'TAO')) | 318 ml = list(m3.merge_lines('LAO', 'TAO')) |
319 self.log('merge result:') | 319 self.log('merge result:') |
320 self.log(''.join(ml)) | 320 self.log(''.join(ml)) |
321 self.assertEquals(ml, MERGED_RESULT) | 321 self.assertEquals(ml, MERGED_RESULT) |
322 | 322 |
323 def test_minimal_conflicts_common(self): | |
324 """Reprocessing""" | |
325 base_text = ("a\n" * 20).splitlines(True) | |
326 this_text = ("a\n"*10+"b\n" * 10).splitlines(True) | |
327 other_text = ("a\n"*10+"c\n"+"b\n" * 8 + "c\n").splitlines(True) | |
328 m3 = Merge3(base_text, other_text, this_text) | |
329 m_lines = m3.merge_lines('OTHER', 'THIS', reprocess=True) | |
330 merged_text = "".join(list(m_lines)) | |
331 optimal_text = ("a\n" * 10 + "<<<<<<< OTHER\nc\n=======\n" | |
332 + ">>>>>>> THIS\n" | |
333 + 8* "b\n" + "<<<<<<< OTHER\nc\n=======\n" | |
334 + 2* "b\n" + ">>>>>>> THIS\n") | |
335 self.assertEquals(optimal_text, merged_text) | |
336 | |
337 def test_minimal_conflicts_unique(self): | |
338 def add_newline(s): | |
339 """Add a newline to each entry in the string""" | |
340 return [(x+'\n') for x in s] | |
341 | |
342 base_text = add_newline("abcdefghijklm") | |
343 this_text = add_newline("abcdefghijklmNOPQRSTUVWXYZ") | |
344 other_text = add_newline("abcdefghijklm1OPQRSTUVWXY2") | |
345 m3 = Merge3(base_text, other_text, this_text) | |
346 m_lines = m3.merge_lines('OTHER', 'THIS', reprocess=True) | |
347 merged_text = "".join(list(m_lines)) | |
348 optimal_text = ''.join(add_newline("abcdefghijklm") | |
349 + ["<<<<<<< OTHER\n1\n=======\nN\n>>>>>>> THIS\n"] | |
350 + add_newline('OPQRSTUVWXY') | |
351 + ["<<<<<<< OTHER\n2\n=======\nZ\n>>>>>>> THIS\n"] | |
352 ) | |
353 self.assertEquals(optimal_text, merged_text) | |
354 | |
355 def test_minimal_conflicts_nonunique(self): | |
356 def add_newline(s): | |
357 """Add a newline to each entry in the string""" | |
358 return [(x+'\n') for x in s] | |
359 | |
360 base_text = add_newline("abacddefgghij") | |
361 this_text = add_newline("abacddefgghijkalmontfprz") | |
362 other_text = add_newline("abacddefgghijknlmontfprd") | |
363 m3 = Merge3(base_text, other_text, this_text) | |
364 m_lines = m3.merge_lines('OTHER', 'THIS', reprocess=True) | |
365 merged_text = "".join(list(m_lines)) | |
366 optimal_text = ''.join(add_newline("abacddefgghijk") | |
367 + ["<<<<<<< OTHER\nn\n=======\na\n>>>>>>> THIS\n"] | |
368 + add_newline('lmontfpr') | |
369 + ["<<<<<<< OTHER\nd\n=======\nz\n>>>>>>> THIS\n"] | |
370 ) | |
371 self.assertEquals(optimal_text, merged_text) | |
372 | |
373 def test_reprocess_and_base(self): | |
374 """Reprocessing and showing base breaks correctly""" | |
375 base_text = ("a\n" * 20).splitlines(True) | |
376 this_text = ("a\n"*10+"b\n" * 10).splitlines(True) | |
377 other_text = ("a\n"*10+"c\n"+"b\n" * 8 + "c\n").splitlines(True) | |
378 m3 = Merge3(base_text, other_text, this_text) | |
379 m_lines = m3.merge_lines('OTHER', 'THIS', reprocess=True, | |
380 base_marker='|||||||') | |
381 self.assertRaises(CantReprocessAndShowBase, list, m_lines) | |
382 | |
383 def test_binary(self): | 323 def test_binary(self): |
384 self.assertRaises(util.Abort, Merge3, ['\x00'], ['a'], ['b']) | 324 self.assertRaises(util.Abort, Merge3, ['\x00'], ['a'], ['b']) |
385 | 325 |
386 def test_dos_text(self): | 326 def test_dos_text(self): |
387 base_text = 'a\r\n' | 327 base_text = 'a\r\n' |