~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_annotate.py

Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
87
87
e
88
88
""".splitlines(True)
89
89
 
 
90
expected_1 = annotation("""\
 
91
blahblah a
 
92
blahblah b
 
93
blahblah c
 
94
blahblah d
 
95
blahblah e
 
96
""")
 
97
 
90
98
 
91
99
new_2 = """\
92
100
a
365
373
 
366
374
class TestReannotate(tests.TestCase):
367
375
 
368
 
    def annotateEqual(self, expected, parents, newlines, revision_id):
 
376
    def annotateEqual(self, expected, parents, newlines, revision_id,
 
377
                      blocks=None):
369
378
        annotate_list = list(annotate.reannotate(parents, newlines,
370
 
                             revision_id))
 
379
                             revision_id, blocks))
371
380
        self.assertEqual(len(expected), len(annotate_list))
372
381
        for e, a in zip(expected, annotate_list):
373
382
            self.assertEqual(e, a)
377
386
        self.annotateEqual(expected_2_1, [parent_2], new_1, 'blahblah')
378
387
        self.annotateEqual(expected_1_2_2, [parent_1, parent_2], new_2, 
379
388
                           'blahblah')
 
389
 
 
390
    def test_reannotate_no_parents(self):
 
391
        self.annotateEqual(expected_1, [], new_1, 'blahblah')
 
392
 
 
393
    def test_reannotate_left_matching_blocks(self):
 
394
        """Ensure that left_matching_blocks has an impact.
 
395
 
 
396
        In this case, the annotation is ambiguous, so the hint isn't actually
 
397
        lying.
 
398
        """
 
399
        parent = [('rev1', 'a\n')]
 
400
        new_text = ['a\n', 'a\n']
 
401
        blocks = [(0, 0, 1), (1, 2, 0)]
 
402
        self.annotateEqual([('rev1', 'a\n'), ('rev2', 'a\n')], [parent],
 
403
                           new_text, 'rev2', blocks)
 
404
        blocks = [(0, 1, 1), (1, 2, 0)]
 
405
        self.annotateEqual([('rev2', 'a\n'), ('rev1', 'a\n')], [parent],
 
406
                           new_text, 'rev2', blocks)