271
274
def assertBranchAnnotate(self, expected, branch, file_id, revision_id,
272
275
verbose=False, full=False, show_ids=False):
273
276
tree = branch.repository.revision_tree(revision_id)
275
278
annotate.annotate_file_tree(tree, file_id, to_file,
276
279
verbose=verbose, full=full, show_ids=show_ids, branch=branch)
277
280
self.assertAnnotateEqualDiff(to_file.getvalue(), expected)
403
406
revtree_2 = tree1.branch.repository.revision_tree('rev-2')
405
408
# this passes if no exception is raised
407
410
annotate.annotate_file_tree(revtree_1, 'a-id',
408
411
to_file=to_file, branch=tree1.branch)
411
to_file = codecs.getwriter('ascii')(sio)
412
to_file.encoding = 'ascii' # codecs does not set it
414
to_file = codecs.getwriter('ascii')(sio, 'replace')
413
415
annotate.annotate_file_tree(revtree_2, 'b-id',
414
416
to_file=to_file, branch=tree1.branch)
415
417
self.assertEqualDiff('2 p?rez | bye\n', sio.getvalue())
417
# test now with to_file.encoding = None
418
to_file = tests.StringIOWrapper()
419
to_file.encoding = None
420
annotate.annotate_file_tree(revtree_2, 'b-id',
421
to_file=to_file, branch=tree1.branch)
422
self.assertContainsRe('2 p.rez | bye\n', to_file.getvalue())
424
# and when it does not exist
426
annotate.annotate_file_tree(revtree_2, 'b-id',
427
to_file=to_file, branch=tree1.branch)
428
self.assertContainsRe('2 p.rez | bye\n', to_file.getvalue())
419
# test now with unicode file-like
420
to_file = StringIOWithEncoding()
421
annotate.annotate_file_tree(revtree_2, 'b-id',
422
to_file=to_file, branch=tree1.branch)
423
self.assertContainsRe(u'2 p\xe9rez | bye\n', to_file.getvalue())
430
425
def test_annotate_author_or_committer(self):
431
426
tree1 = self.make_branch_and_tree('tree1')