def assertBranchAnnotate(self, expected, branch, file_id, revision_id, verbose=False, full=False, show_ids=False): tree = branch.repository.revision_tree(revision_id) to_file = StringIO() annotate.annotate_file_tree( tree, file_id, to_file, verbose=verbose, full=full, show_ids=show_ids, branch=branch ) self.assertAnnotateEqualDiff(to_file.getvalue(), expected)
def test_annotate_unicode_author(self): tree1 = self.make_branch_and_tree('tree1') self.build_tree_contents([('tree1/a', 'adi\xc3\xb3s')]) tree1.add(['a'], ['a-id']) tree1.commit('a', rev_id='rev-1', committer=u'Pepe P\xe9rez <*****@*****.**>', timestamp=1166046000.00, timezone=0) self.build_tree_contents([('tree1/b', 'bye')]) tree1.add(['b'], ['b-id']) tree1.commit('b', rev_id='rev-2', committer=u'p\xe9rez', timestamp=1166046000.00, timezone=0) tree1.lock_read() self.addCleanup(tree1.unlock) revtree_1 = tree1.branch.repository.revision_tree('rev-1') revtree_2 = tree1.branch.repository.revision_tree('rev-2') # this passes if no exception is raised to_file = StringIO() annotate.annotate_file_tree(revtree_1, 'a-id', to_file=to_file, branch=tree1.branch) sio = StringIO() to_file = codecs.getwriter('ascii')(sio) to_file.encoding = 'ascii' # codecs does not set it annotate.annotate_file_tree(revtree_2, 'b-id', to_file=to_file, branch=tree1.branch) self.assertEqualDiff('2 p?rez | bye\n', sio.getvalue()) # test now with to_file.encoding = None to_file = tests.StringIOWrapper() to_file.encoding = None annotate.annotate_file_tree(revtree_2, 'b-id', to_file=to_file, branch=tree1.branch) self.assertContainsRe('2 p.rez | bye\n', to_file.getvalue()) # and when it does not exist to_file = StringIO() annotate.annotate_file_tree(revtree_2, 'b-id', to_file=to_file, branch=tree1.branch) self.assertContainsRe('2 p.rez | bye\n', to_file.getvalue())
def assertBranchAnnotate(self, expected, branch, file_id, revision_id, verbose=False, full=False, show_ids=False): tree = branch.repository.revision_tree(revision_id) to_file = StringIO() annotate.annotate_file_tree(tree, file_id, to_file, verbose=verbose, full=full, show_ids=show_ids, branch=branch) self.assertAnnotateEqualDiff(to_file.getvalue(), expected)
def test_annotate_unicode_author(self): tree1 = self.make_branch_and_tree("tree1") self.build_tree_contents([("tree1/a", "adi\xc3\xb3s")]) tree1.add(["a"], ["a-id"]) tree1.commit( "a", rev_id="rev-1", committer=u"Pepe P\xe9rez <*****@*****.**>", timestamp=1166046000.00, timezone=0 ) self.build_tree_contents([("tree1/b", "bye")]) tree1.add(["b"], ["b-id"]) tree1.commit("b", rev_id="rev-2", committer=u"p\xe9rez", timestamp=1166046000.00, timezone=0) tree1.lock_read() self.addCleanup(tree1.unlock) revtree_1 = tree1.branch.repository.revision_tree("rev-1") revtree_2 = tree1.branch.repository.revision_tree("rev-2") # this passes if no exception is raised to_file = StringIO() annotate.annotate_file_tree(revtree_1, "a-id", to_file=to_file, branch=tree1.branch) sio = StringIO() to_file = codecs.getwriter("ascii")(sio) to_file.encoding = "ascii" # codecs does not set it annotate.annotate_file_tree(revtree_2, "b-id", to_file=to_file, branch=tree1.branch) self.assertEqualDiff("2 p?rez | bye\n", sio.getvalue()) # test now with to_file.encoding = None to_file = tests.StringIOWrapper() to_file.encoding = None annotate.annotate_file_tree(revtree_2, "b-id", to_file=to_file, branch=tree1.branch) self.assertContainsRe("2 p.rez | bye\n", to_file.getvalue()) # and when it does not exist to_file = StringIO() annotate.annotate_file_tree(revtree_2, "b-id", to_file=to_file, branch=tree1.branch) self.assertContainsRe("2 p.rez | bye\n", to_file.getvalue())