Example #1
0
    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())
Example #2
0
    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())
Example #3
0
    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)
        # this passes if no exception is raised
        to_file = StringIO()
        annotate.annotate_file(tree1.branch, 'rev-1', 'a-id', to_file=to_file)

        sio = StringIO()
        to_file = codecs.getwriter('ascii')(sio)
        to_file.encoding = 'ascii' # codecs does not set it
        annotate.annotate_file(tree1.branch, 'rev-2', 'b-id', to_file=to_file)
        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(tree1.branch, 'rev-2', 'b-id', to_file=to_file)
        self.assertContainsRe('2   p.rez   | bye\n', to_file.getvalue())

        # and when it does not exist
        to_file = StringIO()
        annotate.annotate_file(tree1.branch, 'rev-2', 'b-id', to_file=to_file)
        self.assertContainsRe('2   p.rez   | bye\n', to_file.getvalue())