示例#1
0
    def test_annotate_author_or_committer(self):
        tree1 = self.make_branch_and_tree('tree1')

        self.build_tree_contents([('tree1/a', 'hello')])
        tree1.add(['a'], ['a-id'])
        tree1.commit('a', rev_id='rev-1',
                     committer='Committer <*****@*****.**>',
                     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='Committer <*****@*****.**>',
                     author='Author <*****@*****.**>',
                     timestamp=1166046000.00, timezone=0)

        tree1.lock_read()
        self.addCleanup(tree1.unlock)
        to_file = StringIO()
        annotate.annotate_file(tree1.branch, 'rev-1', 'a-id', to_file=to_file)
        self.assertEqual('1   committ | hello\n', to_file.getvalue())

        to_file = StringIO()
        annotate.annotate_file(tree1.branch, 'rev-2', 'b-id', to_file=to_file)
        self.assertEqual('2   author@ | bye\n', to_file.getvalue())
示例#2
0
    def test_annotate_show_ids(self):
        tree1 = self.create_deeply_merged_trees()

        sio = StringIO()
        annotate.annotate_file(tree1.branch, 'rev-6', 'a-id',
                               to_file=sio, show_ids=True, full=False)

        # It looks better with real revision ids :)
        self.assertEqualDiff('    rev-1 | first\n'
                             '    rev-2 | second\n'
                             'rev-1_1_1 | third\n'
                             'rev-1_2_1 | fourth\n'
                             'rev-1_3_1 | fifth\n'
                             '          | sixth\n',
                             sio.getvalue())

        sio = StringIO()
        annotate.annotate_file(tree1.branch, 'rev-6', 'a-id',
                               to_file=sio, show_ids=True, full=True)

        self.assertEqualDiff('    rev-1 | first\n'
                             '    rev-2 | second\n'
                             'rev-1_1_1 | third\n'
                             'rev-1_2_1 | fourth\n'
                             'rev-1_3_1 | fifth\n'
                             'rev-1_3_1 | sixth\n',
                             sio.getvalue())
示例#3
0
    def test_annotate_author_or_committer(self):
        tree1 = self.make_branch_and_tree('tree1')

        self.build_tree_contents([('tree1/a', 'hello')])
        tree1.add(['a'], ['a-id'])
        tree1.commit('a',
                     rev_id='rev-1',
                     committer='Committer <*****@*****.**>',
                     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='Committer <*****@*****.**>',
                     author='Author <*****@*****.**>',
                     timestamp=1166046000.00,
                     timezone=0)

        tree1.lock_read()
        self.addCleanup(tree1.unlock)
        to_file = StringIO()
        annotate.annotate_file(tree1.branch, 'rev-1', 'a-id', to_file=to_file)
        self.assertEqual('1   committ | hello\n', to_file.getvalue())

        to_file = StringIO()
        annotate.annotate_file(tree1.branch, 'rev-2', 'b-id', to_file=to_file)
        self.assertEqual('2   author@ | bye\n', to_file.getvalue())
示例#4
0
    def test_annotate_show_ids(self):
        tree1 = self.create_deeply_merged_trees()

        sio = StringIO()
        annotate.annotate_file(tree1.branch,
                               'rev-6',
                               'a-id',
                               to_file=sio,
                               show_ids=True,
                               full=False)

        # It looks better with real revision ids :)
        self.assertEqualDiff(
            '    rev-1 | first\n'
            '    rev-2 | second\n'
            'rev-1_1_1 | third\n'
            'rev-1_2_1 | fourth\n'
            'rev-1_3_1 | fifth\n'
            '          | sixth\n', sio.getvalue())

        sio = StringIO()
        annotate.annotate_file(tree1.branch,
                               'rev-6',
                               'a-id',
                               to_file=sio,
                               show_ids=True,
                               full=True)

        self.assertEqualDiff(
            '    rev-1 | first\n'
            '    rev-2 | second\n'
            'rev-1_1_1 | third\n'
            'rev-1_2_1 | fourth\n'
            'rev-1_3_1 | fifth\n'
            'rev-1_3_1 | sixth\n', sio.getvalue())
示例#5
0
    def test_annotate_shows_dotted_revnos(self):
        tree1, tree2 = self.create_merged_trees()

        sio = StringIO()
        annotate.annotate_file(tree1.branch, 'rev-3', 'a-id', to_file=sio)
        self.assertEqualDiff(
            '1     joe@foo | first\n'
            '2     joe@foo | second\n'
            '1.1.1 barry@f | third\n', sio.getvalue())
示例#6
0
    def test_annotate_shows_dotted_revnos(self):
        tree1, tree2 = self.create_merged_trees()

        sio = StringIO()
        annotate.annotate_file(tree1.branch, 'rev-3', 'a-id',
                               to_file=sio)
        self.assertEqualDiff('1     joe@foo | first\n'
                             '2     joe@foo | second\n'
                             '1.1.1 barry@f | third\n',
                             sio.getvalue())
示例#7
0
    def test_annotate_uses_branch_context(self):
        """Dotted revnos should use the Branch context.

        When annotating a non-mainline revision, the annotation should still
        use dotted revnos from the mainline.
        """
        tree1 = self.create_deeply_merged_trees()

        sio = StringIO()
        annotate.annotate_file(tree1.branch, 'rev-1_3_1', 'a-id',
                               to_file=sio, verbose=False, full=False)
        self.assertEqualDiff('1     joe@foo | first\n'
                             '1.1.1 barry@f | third\n'
                             '1.2.1 jerry@f | fourth\n'
                             '1.3.1 george@ | fifth\n'
                             '              | sixth\n',
                             sio.getvalue())
示例#8
0
    def test_annotate_uses_branch_context(self):
        """Dotted revnos should use the Branch context.

        When annotating a non-mainline revision, the annotation should still
        use dotted revnos from the mainline.
        """
        tree1 = self.create_deeply_merged_trees()

        sio = StringIO()
        annotate.annotate_file(tree1.branch,
                               'rev-1_3_1',
                               'a-id',
                               to_file=sio,
                               verbose=False,
                               full=False)
        self.assertEqualDiff(
            '1     joe@foo | first\n'
            '1.1.1 barry@f | third\n'
            '1.2.1 jerry@f | fourth\n'
            '1.3.1 george@ | fifth\n'
            '              | sixth\n', sio.getvalue())
示例#9
0
    def test_annotate_limits_dotted_revnos(self):
        """Annotate should limit dotted revnos to a depth of 12"""
        tree1 = self.create_deeply_merged_trees()

        sio = StringIO()
        annotate.annotate_file(tree1.branch, 'rev-6', 'a-id',
                               to_file=sio, verbose=False, full=False)
        self.assertEqualDiff('1     joe@foo | first\n'
                             '2     joe@foo | second\n'
                             '1.1.1 barry@f | third\n'
                             '1.2.1 jerry@f | fourth\n'
                             '1.3.1 george@ | fifth\n'
                             '              | sixth\n',
                             sio.getvalue())

        sio = StringIO()
        annotate.annotate_file(tree1.branch, 'rev-6', 'a-id',
                               to_file=sio, verbose=False, full=True)
        self.assertEqualDiff('1     joe@foo | first\n'
                             '2     joe@foo | second\n'
                             '1.1.1 barry@f | third\n'
                             '1.2.1 jerry@f | fourth\n'
                             '1.3.1 george@ | fifth\n'
                             '1.3.1 george@ | sixth\n',
                             sio.getvalue())

        # verbose=True shows everything, the full revno, user id, and date
        sio = StringIO()
        annotate.annotate_file(tree1.branch, 'rev-6', 'a-id',
                               to_file=sio, verbose=True, full=False)
        self.assertEqualDiff('1     [email protected]    20061213 | first\n'
                             '2     [email protected]    20061213 | second\n'
                             '1.1.1 [email protected]  20061213 | third\n'
                             '1.2.1 [email protected]  20061213 | fourth\n'
                             '1.3.1 [email protected] 20061213 | fifth\n'
                             '                              | sixth\n',
                             sio.getvalue())

        sio = StringIO()
        annotate.annotate_file(tree1.branch, 'rev-6', 'a-id',
                               to_file=sio, verbose=True, full=True)
        self.assertEqualDiff('1     [email protected]    20061213 | first\n'
                             '2     [email protected]    20061213 | second\n'
                             '1.1.1 [email protected]  20061213 | third\n'
                             '1.2.1 [email protected]  20061213 | fourth\n'
                             '1.3.1 [email protected] 20061213 | fifth\n'
                             '1.3.1 [email protected] 20061213 | sixth\n',
                             sio.getvalue())
示例#10
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())
示例#11
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())
示例#12
0
    def test_annotate_limits_dotted_revnos(self):
        """Annotate should limit dotted revnos to a depth of 12"""
        tree1 = self.create_deeply_merged_trees()

        sio = StringIO()
        annotate.annotate_file(tree1.branch,
                               'rev-6',
                               'a-id',
                               to_file=sio,
                               verbose=False,
                               full=False)
        self.assertEqualDiff(
            '1     joe@foo | first\n'
            '2     joe@foo | second\n'
            '1.1.1 barry@f | third\n'
            '1.2.1 jerry@f | fourth\n'
            '1.3.1 george@ | fifth\n'
            '              | sixth\n', sio.getvalue())

        sio = StringIO()
        annotate.annotate_file(tree1.branch,
                               'rev-6',
                               'a-id',
                               to_file=sio,
                               verbose=False,
                               full=True)
        self.assertEqualDiff(
            '1     joe@foo | first\n'
            '2     joe@foo | second\n'
            '1.1.1 barry@f | third\n'
            '1.2.1 jerry@f | fourth\n'
            '1.3.1 george@ | fifth\n'
            '1.3.1 george@ | sixth\n', sio.getvalue())

        # verbose=True shows everything, the full revno, user id, and date
        sio = StringIO()
        annotate.annotate_file(tree1.branch,
                               'rev-6',
                               'a-id',
                               to_file=sio,
                               verbose=True,
                               full=False)
        self.assertEqualDiff(
            '1     [email protected]    20061213 | first\n'
            '2     [email protected]    20061213 | second\n'
            '1.1.1 [email protected]  20061213 | third\n'
            '1.2.1 [email protected]  20061213 | fourth\n'
            '1.3.1 [email protected] 20061213 | fifth\n'
            '                              | sixth\n', sio.getvalue())

        sio = StringIO()
        annotate.annotate_file(tree1.branch,
                               'rev-6',
                               'a-id',
                               to_file=sio,
                               verbose=True,
                               full=True)
        self.assertEqualDiff(
            '1     [email protected]    20061213 | first\n'
            '2     [email protected]    20061213 | second\n'
            '1.1.1 [email protected]  20061213 | third\n'
            '1.2.1 [email protected]  20061213 | fourth\n'
            '1.3.1 [email protected] 20061213 | fifth\n'
            '1.3.1 [email protected] 20061213 | sixth\n', sio.getvalue())