1543
1505
def test_bugs_handler_present(self):
1544
1506
self.properties_handler_registry.get('bugs_properties_handler')
1547
class TestLogForAuthors(TestCaseForLogFormatter):
1550
TestCaseForLogFormatter.setUp(self)
1551
self.wt = self.make_standard_commit('nicky',
1552
authors=['John Doe <jdoe@example.com>',
1553
'Jane Rey <jrey@example.com>'])
1555
def assertFormatterResult(self, formatter, who, result):
1556
formatter_kwargs = dict()
1558
author_list_handler = log.author_list_registry.get(who)
1559
formatter_kwargs['author_list_handler'] = author_list_handler
1560
TestCaseForLogFormatter.assertFormatterResult(self, result,
1561
self.wt.branch, formatter, formatter_kwargs=formatter_kwargs)
1563
def test_line_default(self):
1564
self.assertFormatterResult(log.LineLogFormatter, None, """\
1565
1: John Doe 2005-11-22 add a
1568
def test_line_committer(self):
1569
self.assertFormatterResult(log.LineLogFormatter, 'committer', """\
1570
1: Lorem Ipsum 2005-11-22 add a
1573
def test_line_first(self):
1574
self.assertFormatterResult(log.LineLogFormatter, 'first', """\
1575
1: John Doe 2005-11-22 add a
1578
def test_line_all(self):
1579
self.assertFormatterResult(log.LineLogFormatter, 'all', """\
1580
1: John Doe, Jane Rey 2005-11-22 add a
1584
def test_short_default(self):
1585
self.assertFormatterResult(log.ShortLogFormatter, None, """\
1586
1 John Doe\t2005-11-22
1591
def test_short_committer(self):
1592
self.assertFormatterResult(log.ShortLogFormatter, 'committer', """\
1593
1 Lorem Ipsum\t2005-11-22
1598
def test_short_first(self):
1599
self.assertFormatterResult(log.ShortLogFormatter, 'first', """\
1600
1 John Doe\t2005-11-22
1605
def test_short_all(self):
1606
self.assertFormatterResult(log.ShortLogFormatter, 'all', """\
1607
1 John Doe, Jane Rey\t2005-11-22
1612
def test_long_default(self):
1613
self.assertFormatterResult(log.LongLogFormatter, None, """\
1614
------------------------------------------------------------
1616
author: John Doe <jdoe@example.com>, Jane Rey <jrey@example.com>
1617
committer: Lorem Ipsum <test@example.com>
1619
timestamp: Tue 2005-11-22 00:00:00 +0000
1624
def test_long_committer(self):
1625
self.assertFormatterResult(log.LongLogFormatter, 'committer', """\
1626
------------------------------------------------------------
1628
committer: Lorem Ipsum <test@example.com>
1630
timestamp: Tue 2005-11-22 00:00:00 +0000
1635
def test_long_first(self):
1636
self.assertFormatterResult(log.LongLogFormatter, 'first', """\
1637
------------------------------------------------------------
1639
author: John Doe <jdoe@example.com>
1640
committer: Lorem Ipsum <test@example.com>
1642
timestamp: Tue 2005-11-22 00:00:00 +0000
1647
def test_long_all(self):
1648
self.assertFormatterResult(log.LongLogFormatter, 'all', """\
1649
------------------------------------------------------------
1651
author: John Doe <jdoe@example.com>, Jane Rey <jrey@example.com>
1652
committer: Lorem Ipsum <test@example.com>
1654
timestamp: Tue 2005-11-22 00:00:00 +0000
1659
def test_gnu_changelog_default(self):
1660
self.assertFormatterResult(log.GnuChangelogLogFormatter, None, """\
1661
2005-11-22 John Doe <jdoe@example.com>
1667
def test_gnu_changelog_committer(self):
1668
self.assertFormatterResult(log.GnuChangelogLogFormatter, 'committer', """\
1669
2005-11-22 Lorem Ipsum <test@example.com>
1675
def test_gnu_changelog_first(self):
1676
self.assertFormatterResult(log.GnuChangelogLogFormatter, 'first', """\
1677
2005-11-22 John Doe <jdoe@example.com>
1683
def test_gnu_changelog_all(self):
1684
self.assertFormatterResult(log.GnuChangelogLogFormatter, 'all', """\
1685
2005-11-22 John Doe <jdoe@example.com>, Jane Rey <jrey@example.com>
1691
class TestLogExcludeAncestry(tests.TestCaseWithTransport):
1693
def make_branch_with_alternate_ancestries(self, relpath='.'):
1694
# See test_merge_sorted_exclude_ancestry below for the difference with
1695
# bt.per_branch.test_iter_merge_sorted_revision.
1696
# TestIterMergeSortedRevisionsBushyGraph.
1697
# make_branch_with_alternate_ancestries
1698
# and test_merge_sorted_exclude_ancestry
1699
# See the FIXME in assertLogRevnos too.
1700
builder = branchbuilder.BranchBuilder(self.get_transport(relpath))
1712
builder.start_series()
1713
builder.build_snapshot('1', None, [
1714
('add', ('', 'TREE_ROOT', 'directory', '')),])
1715
builder.build_snapshot('1.1.1', ['1'], [])
1716
builder.build_snapshot('2', ['1'], [])
1717
builder.build_snapshot('1.2.1', ['1.1.1'], [])
1718
builder.build_snapshot('1.1.2', ['1.1.1', '1.2.1'], [])
1719
builder.build_snapshot('3', ['2', '1.1.2'], [])
1720
builder.finish_series()
1721
br = builder.get_branch()
1723
self.addCleanup(br.unlock)
1726
def assertLogRevnos(self, expected_revnos, b, start, end,
1727
exclude_common_ancestry, generate_merge_revisions=True):
1728
# FIXME: the layering in log makes it hard to test intermediate levels,
1729
# I wish adding filters with their parameters were easier...
1731
iter_revs = log._calc_view_revisions(
1732
b, start, end, direction='reverse',
1733
generate_merge_revisions=generate_merge_revisions,
1734
exclude_common_ancestry=exclude_common_ancestry)
1735
self.assertEqual(expected_revnos,
1736
[revid for revid, revno, depth in iter_revs])
1738
def test_merge_sorted_exclude_ancestry(self):
1739
b = self.make_branch_with_alternate_ancestries()
1740
self.assertLogRevnos(['3', '1.1.2', '1.2.1', '1.1.1', '2', '1'],
1741
b, '1', '3', exclude_common_ancestry=False)
1742
# '2' is part of the '3' ancestry but not part of '1.1.1' ancestry so
1743
# it should be mentioned even if merge_sort order will make it appear
1745
self.assertLogRevnos(['3', '1.1.2', '1.2.1', '2'],
1746
b, '1.1.1', '3', exclude_common_ancestry=True)
1748
def test_merge_sorted_simple_revnos_exclude_ancestry(self):
1749
b = self.make_branch_with_alternate_ancestries()
1750
self.assertLogRevnos(['3', '2'],
1751
b, '1', '3', exclude_common_ancestry=True,
1752
generate_merge_revisions=False)
1753
self.assertLogRevnos(['3', '1.1.2', '1.2.1', '1.1.1', '2'],
1754
b, '1', '3', exclude_common_ancestry=True,
1755
generate_merge_revisions=True)