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())
349
def test_annotate_author_or_committer(self):
350
tree1 = self.make_branch_and_tree('tree1')
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)
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)
366
annotate.annotate_file(tree1.branch, 'rev-1', 'a-id', to_file=to_file)
367
self.assertEqual('1 committ | hello\n', to_file.getvalue())
370
annotate.annotate_file(tree1.branch, 'rev-2', 'b-id', to_file=to_file)
371
self.assertEqual('2 author@ | bye\n', to_file.getvalue())
342
374
class TestReannotate(tests.TestCase):
344
def annotateEqual(self, expected, parents, newlines, revision_id):
376
def annotateEqual(self, expected, parents, newlines, revision_id,
345
378
annotate_list = list(annotate.reannotate(parents, newlines,
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,
390
def test_reannotate_no_parents(self):
391
self.annotateEqual(expected_1, [], new_1, 'blahblah')
393
def test_reannotate_left_matching_blocks(self):
394
"""Ensure that left_matching_blocks has an impact.
396
In this case, the annotation is ambiguous, so the hint isn't actually
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)