371
372
wt.branch, log.ShortLogFormatter,
372
373
show_log_kwargs=dict(start_revision=rev, end_revision=rev))
375
def test_show_ids(self):
376
wt = self.make_branch_and_tree('parent')
377
self.build_tree(['parent/f1', 'parent/f2'])
379
self.wt_commit(wt, 'first post', rev_id='a')
380
child_wt = wt.bzrdir.sprout('child').open_workingtree()
381
self.wt_commit(child_wt, 'branch 1 changes', rev_id='b')
382
wt.merge_from_branch(child_wt.branch)
383
self.wt_commit(wt, 'merge branch 1', rev_id='c')
384
self.assertFormatterResult("""\
385
2 Joe Foo\t2005-11-22 [merge]
389
1.1.1 Joe Foo\t2005-11-22
393
1 Joe Foo\t2005-11-22
398
wt.branch, log.ShortLogFormatter,
399
formatter_kwargs=dict(levels=0,show_ids=True))
375
402
class TestShortLogFormatterWithMergeRevisions(TestCaseForLogFormatter):
659
686
self.assertEqualDiff('''custom_prop_name: test_value\n''',
689
def test_show_ids(self):
690
wt = self.make_branch_and_tree('parent')
691
self.build_tree(['parent/f1', 'parent/f2'])
693
self.wt_commit(wt, 'first post', rev_id='a')
694
child_wt = wt.bzrdir.sprout('child').open_workingtree()
695
self.wt_commit(child_wt, 'branch 1 changes', rev_id='b')
696
wt.merge_from_branch(child_wt.branch)
697
self.wt_commit(wt, 'merge branch 1', rev_id='c')
698
self.assertFormatterResult("""\
699
------------------------------------------------------------
704
committer: Joe Foo <joe@foo.com>
706
timestamp: Tue 2005-11-22 00:00:02 +0000
709
------------------------------------------------------------
713
committer: Joe Foo <joe@foo.com>
715
timestamp: Tue 2005-11-22 00:00:01 +0000
718
------------------------------------------------------------
721
committer: Joe Foo <joe@foo.com>
723
timestamp: Tue 2005-11-22 00:00:00 +0000
727
wt.branch, log.LongLogFormatter,
728
formatter_kwargs=dict(levels=0,show_ids=True))
663
731
class TestLongLogFormatterWithoutMergeRevisions(TestCaseForLogFormatter):
1463
1531
self.assertNotContainsRe(s.getvalue(), 'Added Revisions:')
1534
class TestRevisionNotInBranch(TestCaseForLogFormatter):
1536
def setup_a_tree(self):
1537
tree = self.make_branch_and_tree('tree')
1539
self.addCleanup(tree.unlock)
1541
'committer': 'Joe Foo <joe@foo.com>',
1542
'timestamp': 1132617600, # Mon 2005-11-22 00:00:00 +0000
1544
tree.commit('commit 1a', rev_id='1a', **kwargs)
1545
tree.commit('commit 2a', rev_id='2a', **kwargs)
1546
tree.commit('commit 3a', rev_id='3a', **kwargs)
1549
def setup_ab_tree(self):
1550
tree = self.setup_a_tree()
1551
tree.set_last_revision('1a')
1552
tree.branch.set_last_revision_info(1, '1a')
1554
'committer': 'Joe Foo <joe@foo.com>',
1555
'timestamp': 1132617600, # Mon 2005-11-22 00:00:00 +0000
1557
tree.commit('commit 2b', rev_id='2b', **kwargs)
1558
tree.commit('commit 3b', rev_id='3b', **kwargs)
1561
def test_one_revision(self):
1562
tree = self.setup_ab_tree()
1564
rev = revisionspec.RevisionInfo(tree.branch, None, '3a')
1565
log.show_log(tree.branch, lf, verbose=True, start_revision=rev,
1567
self.assertEqual(1, len(lf.revisions))
1568
self.assertEqual(None, lf.revisions[0].revno) # Out-of-branch
1569
self.assertEqual('3a', lf.revisions[0].rev.revision_id)
1571
def test_many_revisions(self):
1572
tree = self.setup_ab_tree()
1574
start_rev = revisionspec.RevisionInfo(tree.branch, None, '1a')
1575
end_rev = revisionspec.RevisionInfo(tree.branch, None, '3a')
1576
log.show_log(tree.branch, lf, verbose=True, start_revision=start_rev,
1577
end_revision=end_rev)
1578
self.assertEqual(3, len(lf.revisions))
1579
self.assertEqual(None, lf.revisions[0].revno) # Out-of-branch
1580
self.assertEqual('3a', lf.revisions[0].rev.revision_id)
1581
self.assertEqual(None, lf.revisions[1].revno) # Out-of-branch
1582
self.assertEqual('2a', lf.revisions[1].rev.revision_id)
1583
self.assertEqual('1', lf.revisions[2].revno) # In-branch
1585
def test_long_format(self):
1586
tree = self.setup_ab_tree()
1587
start_rev = revisionspec.RevisionInfo(tree.branch, None, '1a')
1588
end_rev = revisionspec.RevisionInfo(tree.branch, None, '3a')
1589
self.assertFormatterResult("""\
1590
------------------------------------------------------------
1592
committer: Joe Foo <joe@foo.com>
1594
timestamp: Tue 2005-11-22 11:00:00 +1100
1597
------------------------------------------------------------
1599
committer: Joe Foo <joe@foo.com>
1601
timestamp: Tue 2005-11-22 11:00:00 +1100
1604
------------------------------------------------------------
1606
committer: Joe Foo <joe@foo.com>
1608
timestamp: Tue 2005-11-22 11:00:00 +1100
1612
tree.branch, log.LongLogFormatter, show_log_kwargs={
1613
'start_revision': start_rev, 'end_revision': end_rev
1616
def test_short_format(self):
1617
tree = self.setup_ab_tree()
1618
start_rev = revisionspec.RevisionInfo(tree.branch, None, '1a')
1619
end_rev = revisionspec.RevisionInfo(tree.branch, None, '3a')
1620
self.assertFormatterResult("""\
1629
1 Joe Foo\t2005-11-22
1633
tree.branch, log.ShortLogFormatter, show_log_kwargs={
1634
'start_revision': start_rev, 'end_revision': end_rev
1637
def test_line_format(self):
1638
tree = self.setup_ab_tree()
1639
start_rev = revisionspec.RevisionInfo(tree.branch, None, '1a')
1640
end_rev = revisionspec.RevisionInfo(tree.branch, None, '3a')
1641
self.assertFormatterResult("""\
1642
Joe Foo 2005-11-22 commit 3a
1643
Joe Foo 2005-11-22 commit 2a
1644
1: Joe Foo 2005-11-22 commit 1a
1646
tree.branch, log.LineLogFormatter, show_log_kwargs={
1647
'start_revision': start_rev, 'end_revision': end_rev
1467
1651
class TestLogWithBugs(TestCaseForLogFormatter, TestLogMixin):
1543
1727
def test_bugs_handler_present(self):
1544
1728
self.properties_handler_registry.get('bugs_properties_handler')
1731
class TestLogForAuthors(TestCaseForLogFormatter):
1734
TestCaseForLogFormatter.setUp(self)
1735
self.wt = self.make_standard_commit('nicky',
1736
authors=['John Doe <jdoe@example.com>',
1737
'Jane Rey <jrey@example.com>'])
1739
def assertFormatterResult(self, formatter, who, result):
1740
formatter_kwargs = dict()
1742
author_list_handler = log.author_list_registry.get(who)
1743
formatter_kwargs['author_list_handler'] = author_list_handler
1744
TestCaseForLogFormatter.assertFormatterResult(self, result,
1745
self.wt.branch, formatter, formatter_kwargs=formatter_kwargs)
1747
def test_line_default(self):
1748
self.assertFormatterResult(log.LineLogFormatter, None, """\
1749
1: John Doe 2005-11-22 add a
1752
def test_line_committer(self):
1753
self.assertFormatterResult(log.LineLogFormatter, 'committer', """\
1754
1: Lorem Ipsum 2005-11-22 add a
1757
def test_line_first(self):
1758
self.assertFormatterResult(log.LineLogFormatter, 'first', """\
1759
1: John Doe 2005-11-22 add a
1762
def test_line_all(self):
1763
self.assertFormatterResult(log.LineLogFormatter, 'all', """\
1764
1: John Doe, Jane Rey 2005-11-22 add a
1768
def test_short_default(self):
1769
self.assertFormatterResult(log.ShortLogFormatter, None, """\
1770
1 John Doe\t2005-11-22
1775
def test_short_committer(self):
1776
self.assertFormatterResult(log.ShortLogFormatter, 'committer', """\
1777
1 Lorem Ipsum\t2005-11-22
1782
def test_short_first(self):
1783
self.assertFormatterResult(log.ShortLogFormatter, 'first', """\
1784
1 John Doe\t2005-11-22
1789
def test_short_all(self):
1790
self.assertFormatterResult(log.ShortLogFormatter, 'all', """\
1791
1 John Doe, Jane Rey\t2005-11-22
1796
def test_long_default(self):
1797
self.assertFormatterResult(log.LongLogFormatter, None, """\
1798
------------------------------------------------------------
1800
author: John Doe <jdoe@example.com>, Jane Rey <jrey@example.com>
1801
committer: Lorem Ipsum <test@example.com>
1803
timestamp: Tue 2005-11-22 00:00:00 +0000
1808
def test_long_committer(self):
1809
self.assertFormatterResult(log.LongLogFormatter, 'committer', """\
1810
------------------------------------------------------------
1812
committer: Lorem Ipsum <test@example.com>
1814
timestamp: Tue 2005-11-22 00:00:00 +0000
1819
def test_long_first(self):
1820
self.assertFormatterResult(log.LongLogFormatter, 'first', """\
1821
------------------------------------------------------------
1823
author: John Doe <jdoe@example.com>
1824
committer: Lorem Ipsum <test@example.com>
1826
timestamp: Tue 2005-11-22 00:00:00 +0000
1831
def test_long_all(self):
1832
self.assertFormatterResult(log.LongLogFormatter, 'all', """\
1833
------------------------------------------------------------
1835
author: John Doe <jdoe@example.com>, Jane Rey <jrey@example.com>
1836
committer: Lorem Ipsum <test@example.com>
1838
timestamp: Tue 2005-11-22 00:00:00 +0000
1843
def test_gnu_changelog_default(self):
1844
self.assertFormatterResult(log.GnuChangelogLogFormatter, None, """\
1845
2005-11-22 John Doe <jdoe@example.com>
1851
def test_gnu_changelog_committer(self):
1852
self.assertFormatterResult(log.GnuChangelogLogFormatter, 'committer', """\
1853
2005-11-22 Lorem Ipsum <test@example.com>
1859
def test_gnu_changelog_first(self):
1860
self.assertFormatterResult(log.GnuChangelogLogFormatter, 'first', """\
1861
2005-11-22 John Doe <jdoe@example.com>
1867
def test_gnu_changelog_all(self):
1868
self.assertFormatterResult(log.GnuChangelogLogFormatter, 'all', """\
1869
2005-11-22 John Doe <jdoe@example.com>, Jane Rey <jrey@example.com>
1546
1876
class TestLogExcludeAncestry(tests.TestCaseWithTransport):
1548
1878
def make_branch_with_alternate_ancestries(self, relpath='.'):
1581
1911
def assertLogRevnos(self, expected_revnos, b, start, end,
1582
exclude_common_ancestry):
1912
exclude_common_ancestry, generate_merge_revisions=True):
1583
1913
# FIXME: the layering in log makes it hard to test intermediate levels,
1584
1914
# I wish adding filters with their parameters were easier...
1585
1915
# -- vila 20100413
1586
1916
iter_revs = log._calc_view_revisions(
1587
1917
b, start, end, direction='reverse',
1588
generate_merge_revisions=True,
1918
generate_merge_revisions=generate_merge_revisions,
1589
1919
exclude_common_ancestry=exclude_common_ancestry)
1590
1920
self.assertEqual(expected_revnos,
1591
1921
[revid for revid, revno, depth in iter_revs])
1593
1923
def test_merge_sorted_exclude_ancestry(self):
1594
1924
b = self.make_branch_with_alternate_ancestries()
1595
1925
self.assertLogRevnos(['3', '1.1.2', '1.2.1', '1.1.1', '2', '1'],
1926
b, '1', '3', exclude_common_ancestry=False)
1597
1927
# '2' is part of the '3' ancestry but not part of '1.1.1' ancestry so
1598
1928
# it should be mentioned even if merge_sort order will make it appear
1600
1930
self.assertLogRevnos(['3', '1.1.2', '1.2.1', '2'],
1601
b, '1.1.1', '3', True)
1931
b, '1.1.1', '3', exclude_common_ancestry=True)
1933
def test_merge_sorted_simple_revnos_exclude_ancestry(self):
1934
b = self.make_branch_with_alternate_ancestries()
1935
self.assertLogRevnos(['3', '2'],
1936
b, '1', '3', exclude_common_ancestry=True,
1937
generate_merge_revisions=False)
1938
self.assertLogRevnos(['3', '1.1.2', '1.2.1', '1.1.1', '2'],
1939
b, '1', '3', exclude_common_ancestry=True,
1940
generate_merge_revisions=True)