~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/selftest/testmerge3.py

  • Committer: Martin Pool
  • Date: 2005-08-29 03:42:38 UTC
  • Revision ID: mbp@sourcefrog.net-20050829034238-0a9b4fb9a6ce201f
- test code exercises a successful check and null upgrade of a branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
17
 
18
 
from bzrlib.tests import TestCaseInTempDir, TestCase
 
18
from bzrlib.selftest import InTempDir, TestCase
19
19
from bzrlib.merge3 import Merge3
20
 
from bzrlib.errors import CantReprocessAndShowBase
21
20
 
22
21
def split_lines(t):
23
22
    from cStringIO import StringIO
83
82
     The two are the same,
84
83
     But after they are produced,
85
84
       they have different names.
86
 
<<<<<<< LAO
87
 
=======
 
85
<<<<<<<< LAO
 
86
========
88
87
     
89
88
       -- The Way of Lao-Tzu, tr. Wing-tsit Chan
90
89
 
91
 
>>>>>>> TAO
 
90
>>>>>>>> TAO
92
91
""")
93
92
 
94
93
class TestMerge3(TestCase):
222
221
                            start_marker='<<',
223
222
                            mid_marker='--',
224
223
                            end_marker='>>')
225
 
        self.assertEquals(''.join(ml), 'aaa\n222\nbbb\n')
226
 
        
 
224
        self.assertEquals(''.join(m3.merge_lines()),
 
225
                          'aaa\n222\nbbb\n')
227
226
 
228
227
    def test_insert_clash(self):
229
228
        """Both try to insert lines in the same place."""
302
301
        self.log(''.join(ml))
303
302
        self.assertEquals(ml, MERGED_RESULT)
304
303
 
305
 
    def test_minimal_conflicts(self):
306
 
        """Reprocessing"""
307
 
        base_text = ("a\n" * 20).splitlines(True)
308
 
        this_text = ("a\n"*10+"b\n" * 10).splitlines(True)
309
 
        other_text = ("a\n"*10+"c\n"+"b\n" * 8 + "c\n").splitlines(True)
310
 
        m3 = Merge3(base_text, other_text, this_text)
311
 
        m_lines = m3.merge_lines('OTHER', 'THIS', reprocess=True)
312
 
        merged_text = "".join(list(m_lines))
313
 
        optimal_text = "a\n" * 10 + "<<<<<<< OTHER\nc\n=======\n>>>>>>> THIS"\
314
 
            + "\n" + 8* "b\n" + "<<<<<<< OTHER\nc\n=======\nb\nb\n>>>>>>>"\
315
 
            + " THIS\n"
316
 
        self.assertEqualDiff(merged_text, optimal_text)
317
304
 
318
 
    def test_reprocess_and_base(self):
319
 
        """Reprocessing and showing base breaks correctly"""
320
 
        base_text = ("a\n" * 20).splitlines(True)
321
 
        this_text = ("a\n"*10+"b\n" * 10).splitlines(True)
322
 
        other_text = ("a\n"*10+"c\n"+"b\n" * 8 + "c\n").splitlines(True)
323
 
        m3 = Merge3(base_text, other_text, this_text)
324
 
        m_lines = m3.merge_lines('OTHER', 'THIS', reprocess=True, 
325
 
                                 base_marker='|||||||')
326
 
        self.assertRaises(CantReprocessAndShowBase, list, m_lines)
 
305
TEST_CLASSES = [ TestMerge3 ]