372
371
wt.branch, log.ShortLogFormatter,
373
372
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))
402
375
class TestShortLogFormatterWithMergeRevisions(TestCaseForLogFormatter):
686
659
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))
731
663
class TestLongLogFormatterWithoutMergeRevisions(TestCaseForLogFormatter):
1531
1463
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
1543
'timezone': 0, # UTC
1545
tree.commit('commit 1a', rev_id='1a', **kwargs)
1546
tree.commit('commit 2a', rev_id='2a', **kwargs)
1547
tree.commit('commit 3a', rev_id='3a', **kwargs)
1550
def setup_ab_tree(self):
1551
tree = self.setup_a_tree()
1552
tree.set_last_revision('1a')
1553
tree.branch.set_last_revision_info(1, '1a')
1555
'committer': 'Joe Foo <joe@foo.com>',
1556
'timestamp': 1132617600, # Mon 2005-11-22 00:00:00 +0000
1557
'timezone': 0, # UTC
1559
tree.commit('commit 2b', rev_id='2b', **kwargs)
1560
tree.commit('commit 3b', rev_id='3b', **kwargs)
1563
def test_one_revision(self):
1564
tree = self.setup_ab_tree()
1566
rev = revisionspec.RevisionInfo(tree.branch, None, '3a')
1567
log.show_log(tree.branch, lf, verbose=True, start_revision=rev,
1569
self.assertEqual(1, len(lf.revisions))
1570
self.assertEqual(None, lf.revisions[0].revno) # Out-of-branch
1571
self.assertEqual('3a', lf.revisions[0].rev.revision_id)
1573
def test_many_revisions(self):
1574
tree = self.setup_ab_tree()
1576
start_rev = revisionspec.RevisionInfo(tree.branch, None, '1a')
1577
end_rev = revisionspec.RevisionInfo(tree.branch, None, '3a')
1578
log.show_log(tree.branch, lf, verbose=True, start_revision=start_rev,
1579
end_revision=end_rev)
1580
self.assertEqual(3, len(lf.revisions))
1581
self.assertEqual(None, lf.revisions[0].revno) # Out-of-branch
1582
self.assertEqual('3a', lf.revisions[0].rev.revision_id)
1583
self.assertEqual(None, lf.revisions[1].revno) # Out-of-branch
1584
self.assertEqual('2a', lf.revisions[1].rev.revision_id)
1585
self.assertEqual('1', lf.revisions[2].revno) # In-branch
1587
def test_long_format(self):
1588
tree = self.setup_ab_tree()
1589
start_rev = revisionspec.RevisionInfo(tree.branch, None, '1a')
1590
end_rev = revisionspec.RevisionInfo(tree.branch, None, '3a')
1591
self.assertFormatterResult("""\
1592
------------------------------------------------------------
1594
committer: Joe Foo <joe@foo.com>
1596
timestamp: Tue 2005-11-22 00:00:00 +0000
1599
------------------------------------------------------------
1601
committer: Joe Foo <joe@foo.com>
1603
timestamp: Tue 2005-11-22 00:00:00 +0000
1606
------------------------------------------------------------
1608
committer: Joe Foo <joe@foo.com>
1610
timestamp: Tue 2005-11-22 00:00:00 +0000
1614
tree.branch, log.LongLogFormatter, show_log_kwargs={
1615
'start_revision': start_rev, 'end_revision': end_rev
1618
def test_short_format(self):
1619
tree = self.setup_ab_tree()
1620
start_rev = revisionspec.RevisionInfo(tree.branch, None, '1a')
1621
end_rev = revisionspec.RevisionInfo(tree.branch, None, '3a')
1622
self.assertFormatterResult("""\
1631
1 Joe Foo\t2005-11-22
1635
tree.branch, log.ShortLogFormatter, show_log_kwargs={
1636
'start_revision': start_rev, 'end_revision': end_rev
1639
def test_line_format(self):
1640
tree = self.setup_ab_tree()
1641
start_rev = revisionspec.RevisionInfo(tree.branch, None, '1a')
1642
end_rev = revisionspec.RevisionInfo(tree.branch, None, '3a')
1643
self.assertFormatterResult("""\
1644
Joe Foo 2005-11-22 commit 3a
1645
Joe Foo 2005-11-22 commit 2a
1646
1: Joe Foo 2005-11-22 commit 1a
1648
tree.branch, log.LineLogFormatter, show_log_kwargs={
1649
'start_revision': start_rev, 'end_revision': end_rev
1653
1467
class TestLogWithBugs(TestCaseForLogFormatter, TestLogMixin):
1729
1543
def test_bugs_handler_present(self):
1730
1544
self.properties_handler_registry.get('bugs_properties_handler')
1733
class TestLogForAuthors(TestCaseForLogFormatter):
1736
TestCaseForLogFormatter.setUp(self)
1737
self.wt = self.make_standard_commit('nicky',
1738
authors=['John Doe <jdoe@example.com>',
1739
'Jane Rey <jrey@example.com>'])
1741
def assertFormatterResult(self, formatter, who, result):
1742
formatter_kwargs = dict()
1744
author_list_handler = log.author_list_registry.get(who)
1745
formatter_kwargs['author_list_handler'] = author_list_handler
1746
TestCaseForLogFormatter.assertFormatterResult(self, result,
1747
self.wt.branch, formatter, formatter_kwargs=formatter_kwargs)
1749
def test_line_default(self):
1750
self.assertFormatterResult(log.LineLogFormatter, None, """\
1751
1: John Doe 2005-11-22 add a
1754
def test_line_committer(self):
1755
self.assertFormatterResult(log.LineLogFormatter, 'committer', """\
1756
1: Lorem Ipsum 2005-11-22 add a
1759
def test_line_first(self):
1760
self.assertFormatterResult(log.LineLogFormatter, 'first', """\
1761
1: John Doe 2005-11-22 add a
1764
def test_line_all(self):
1765
self.assertFormatterResult(log.LineLogFormatter, 'all', """\
1766
1: John Doe, Jane Rey 2005-11-22 add a
1770
def test_short_default(self):
1771
self.assertFormatterResult(log.ShortLogFormatter, None, """\
1772
1 John Doe\t2005-11-22
1777
def test_short_committer(self):
1778
self.assertFormatterResult(log.ShortLogFormatter, 'committer', """\
1779
1 Lorem Ipsum\t2005-11-22
1784
def test_short_first(self):
1785
self.assertFormatterResult(log.ShortLogFormatter, 'first', """\
1786
1 John Doe\t2005-11-22
1791
def test_short_all(self):
1792
self.assertFormatterResult(log.ShortLogFormatter, 'all', """\
1793
1 John Doe, Jane Rey\t2005-11-22
1798
def test_long_default(self):
1799
self.assertFormatterResult(log.LongLogFormatter, None, """\
1800
------------------------------------------------------------
1802
author: John Doe <jdoe@example.com>, Jane Rey <jrey@example.com>
1803
committer: Lorem Ipsum <test@example.com>
1805
timestamp: Tue 2005-11-22 00:00:00 +0000
1810
def test_long_committer(self):
1811
self.assertFormatterResult(log.LongLogFormatter, 'committer', """\
1812
------------------------------------------------------------
1814
committer: Lorem Ipsum <test@example.com>
1816
timestamp: Tue 2005-11-22 00:00:00 +0000
1821
def test_long_first(self):
1822
self.assertFormatterResult(log.LongLogFormatter, 'first', """\
1823
------------------------------------------------------------
1825
author: John Doe <jdoe@example.com>
1826
committer: Lorem Ipsum <test@example.com>
1828
timestamp: Tue 2005-11-22 00:00:00 +0000
1833
def test_long_all(self):
1834
self.assertFormatterResult(log.LongLogFormatter, 'all', """\
1835
------------------------------------------------------------
1837
author: John Doe <jdoe@example.com>, Jane Rey <jrey@example.com>
1838
committer: Lorem Ipsum <test@example.com>
1840
timestamp: Tue 2005-11-22 00:00:00 +0000
1845
def test_gnu_changelog_default(self):
1846
self.assertFormatterResult(log.GnuChangelogLogFormatter, None, """\
1847
2005-11-22 John Doe <jdoe@example.com>
1853
def test_gnu_changelog_committer(self):
1854
self.assertFormatterResult(log.GnuChangelogLogFormatter, 'committer', """\
1855
2005-11-22 Lorem Ipsum <test@example.com>
1861
def test_gnu_changelog_first(self):
1862
self.assertFormatterResult(log.GnuChangelogLogFormatter, 'first', """\
1863
2005-11-22 John Doe <jdoe@example.com>
1869
def test_gnu_changelog_all(self):
1870
self.assertFormatterResult(log.GnuChangelogLogFormatter, 'all', """\
1871
2005-11-22 John Doe <jdoe@example.com>, Jane Rey <jrey@example.com>
1878
1546
class TestLogExcludeAncestry(tests.TestCaseWithTransport):
1880
1548
def make_branch_with_alternate_ancestries(self, relpath='.'):
1913
1581
def assertLogRevnos(self, expected_revnos, b, start, end,
1914
exclude_common_ancestry, generate_merge_revisions=True):
1582
exclude_common_ancestry):
1915
1583
# FIXME: the layering in log makes it hard to test intermediate levels,
1916
1584
# I wish adding filters with their parameters were easier...
1917
1585
# -- vila 20100413
1918
1586
iter_revs = log._calc_view_revisions(
1919
1587
b, start, end, direction='reverse',
1920
generate_merge_revisions=generate_merge_revisions,
1588
generate_merge_revisions=True,
1921
1589
exclude_common_ancestry=exclude_common_ancestry)
1922
1590
self.assertEqual(expected_revnos,
1923
1591
[revid for revid, revno, depth in iter_revs])
1925
1593
def test_merge_sorted_exclude_ancestry(self):
1926
1594
b = self.make_branch_with_alternate_ancestries()
1927
1595
self.assertLogRevnos(['3', '1.1.2', '1.2.1', '1.1.1', '2', '1'],
1928
b, '1', '3', exclude_common_ancestry=False)
1929
1597
# '2' is part of the '3' ancestry but not part of '1.1.1' ancestry so
1930
1598
# it should be mentioned even if merge_sort order will make it appear
1932
1600
self.assertLogRevnos(['3', '1.1.2', '1.2.1', '2'],
1933
b, '1.1.1', '3', exclude_common_ancestry=True)
1601
b, '1.1.1', '3', True)
1935
def test_merge_sorted_simple_revnos_exclude_ancestry(self):
1936
b = self.make_branch_with_alternate_ancestries()
1937
self.assertLogRevnos(['3', '2'],
1938
b, '1', '3', exclude_common_ancestry=True,
1939
generate_merge_revisions=False)
1940
self.assertLogRevnos(['3', '1.1.2', '1.2.1', '1.1.1', '2'],
1941
b, '1', '3', exclude_common_ancestry=True,
1942
generate_merge_revisions=True)