/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_annotate.py

  • Committer: Martin Pool
  • Date: 2007-09-03 04:35:49 UTC
  • mfrom: (2778 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2779.
  • Revision ID: mbp@sourcefrog.net-20070903043549-0cfyrgx7z2h8ppks
merge trunk

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
338
346
        annotate.annotate_file(tree1.branch, 'rev-2', 'b-id', to_file=to_file)
339
347
        self.assertContainsRe('2   p.rez   | bye\n', to_file.getvalue())
340
348
 
 
349
    def test_annotate_author_or_committer(self):
 
350
        tree1 = self.make_branch_and_tree('tree1')
 
351
 
 
352
        self.build_tree_contents([('tree1/a', 'hello')])
 
353
        tree1.add(['a'], ['a-id'])
 
354
        tree1.commit('a', rev_id='rev-1',
 
355
                     committer='Committer <committer@example.com>',
 
356
                     timestamp=1166046000.00, timezone=0)
 
357
 
 
358
        self.build_tree_contents([('tree1/b', 'bye')])
 
359
        tree1.add(['b'], ['b-id'])
 
360
        tree1.commit('b', rev_id='rev-2',
 
361
                     committer='Committer <committer@example.com>',
 
362
                     author='Author <author@example.com>',
 
363
                     timestamp=1166046000.00, timezone=0)
 
364
 
 
365
        to_file = StringIO()
 
366
        annotate.annotate_file(tree1.branch, 'rev-1', 'a-id', to_file=to_file)
 
367
        self.assertEqual('1   committ | hello\n', to_file.getvalue())
 
368
 
 
369
        to_file = StringIO()
 
370
        annotate.annotate_file(tree1.branch, 'rev-2', 'b-id', to_file=to_file)
 
371
        self.assertEqual('2   author@ | bye\n', to_file.getvalue())
 
372
 
341
373
 
342
374
class TestReannotate(tests.TestCase):
343
375
 
344
 
    def annotateEqual(self, expected, parents, newlines, revision_id):
 
376
    def annotateEqual(self, expected, parents, newlines, revision_id,
 
377
                      blocks=None):
345
378
        annotate_list = list(annotate.reannotate(parents, newlines,
346
 
                             revision_id))
 
379
                             revision_id, blocks))
347
380
        self.assertEqual(len(expected), len(annotate_list))
348
381
        for e, a in zip(expected, annotate_list):
349
382
            self.assertEqual(e, a)
353
386
        self.annotateEqual(expected_2_1, [parent_2], new_1, 'blahblah')
354
387
        self.annotateEqual(expected_1_2_2, [parent_1, parent_2], new_2, 
355
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)