~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_log.py

(jameinel) Fix bug #397739,
 resolve 'lp:foo' locally as long as we have a launchpad-login to use
 bzr+ssh. (John A Meinel)

Show diffs side-by-side

added added

removed removed

Lines of Context:
117
117
            branch.tags.set_tag('v1.0', 'rev-3')
118
118
        return wt
119
119
 
 
120
 
120
121
class LogCatcher(log.LogFormatter):
121
122
    """Pull log messages into a list rather than displaying them.
122
123
 
371
372
            wt.branch, log.ShortLogFormatter,
372
373
            show_log_kwargs=dict(start_revision=rev, end_revision=rev))
373
374
 
 
375
    def test_show_ids(self):
 
376
        wt = self.make_branch_and_tree('parent')
 
377
        self.build_tree(['parent/f1', 'parent/f2'])
 
378
        wt.add(['f1','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]
 
386
      revision-id:c
 
387
      merge branch 1
 
388
 
 
389
          1.1.1 Joe Foo\t2005-11-22
 
390
                revision-id:b
 
391
                branch 1 changes
 
392
 
 
393
    1 Joe Foo\t2005-11-22
 
394
      revision-id:a
 
395
      first post
 
396
 
 
397
""",
 
398
            wt.branch, log.ShortLogFormatter,
 
399
            formatter_kwargs=dict(levels=0,show_ids=True))
 
400
 
374
401
 
375
402
class TestShortLogFormatterWithMergeRevisions(TestCaseForLogFormatter):
376
403
 
659
686
        self.assertEqualDiff('''custom_prop_name: test_value\n''',
660
687
                             sio.getvalue())
661
688
 
 
689
    def test_show_ids(self):
 
690
        wt = self.make_branch_and_tree('parent')
 
691
        self.build_tree(['parent/f1', 'parent/f2'])
 
692
        wt.add(['f1','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
------------------------------------------------------------
 
700
revno: 2 [merge]
 
701
revision-id: c
 
702
parent: a
 
703
parent: b
 
704
committer: Joe Foo <joe@foo.com>
 
705
branch nick: parent
 
706
timestamp: Tue 2005-11-22 00:00:02 +0000
 
707
message:
 
708
  merge branch 1
 
709
    ------------------------------------------------------------
 
710
    revno: 1.1.1
 
711
    revision-id: b
 
712
    parent: a
 
713
    committer: Joe Foo <joe@foo.com>
 
714
    branch nick: child
 
715
    timestamp: Tue 2005-11-22 00:00:01 +0000
 
716
    message:
 
717
      branch 1 changes
 
718
------------------------------------------------------------
 
719
revno: 1
 
720
revision-id: a
 
721
committer: Joe Foo <joe@foo.com>
 
722
branch nick: parent
 
723
timestamp: Tue 2005-11-22 00:00:00 +0000
 
724
message:
 
725
  first post
 
726
""",
 
727
            wt.branch, log.LongLogFormatter,
 
728
            formatter_kwargs=dict(levels=0,show_ids=True))
 
729
 
662
730
 
663
731
class TestLongLogFormatterWithoutMergeRevisions(TestCaseForLogFormatter):
664
732
 
1543
1611
    def test_bugs_handler_present(self):
1544
1612
        self.properties_handler_registry.get('bugs_properties_handler')
1545
1613
 
 
1614
 
 
1615
class TestLogForAuthors(TestCaseForLogFormatter):
 
1616
 
 
1617
    def setUp(self):
 
1618
        TestCaseForLogFormatter.setUp(self)
 
1619
        self.wt = self.make_standard_commit('nicky',
 
1620
            authors=['John Doe <jdoe@example.com>',
 
1621
                     'Jane Rey <jrey@example.com>'])
 
1622
 
 
1623
    def assertFormatterResult(self, formatter, who, result):
 
1624
        formatter_kwargs = dict()
 
1625
        if who is not None:
 
1626
            author_list_handler = log.author_list_registry.get(who)
 
1627
            formatter_kwargs['author_list_handler'] = author_list_handler
 
1628
        TestCaseForLogFormatter.assertFormatterResult(self, result,
 
1629
            self.wt.branch, formatter, formatter_kwargs=formatter_kwargs)
 
1630
 
 
1631
    def test_line_default(self):
 
1632
        self.assertFormatterResult(log.LineLogFormatter, None, """\
 
1633
1: John Doe 2005-11-22 add a
 
1634
""")
 
1635
 
 
1636
    def test_line_committer(self):
 
1637
        self.assertFormatterResult(log.LineLogFormatter, 'committer', """\
 
1638
1: Lorem Ipsum 2005-11-22 add a
 
1639
""")
 
1640
 
 
1641
    def test_line_first(self):
 
1642
        self.assertFormatterResult(log.LineLogFormatter, 'first', """\
 
1643
1: John Doe 2005-11-22 add a
 
1644
""")
 
1645
 
 
1646
    def test_line_all(self):
 
1647
        self.assertFormatterResult(log.LineLogFormatter, 'all', """\
 
1648
1: John Doe, Jane Rey 2005-11-22 add a
 
1649
""")
 
1650
 
 
1651
 
 
1652
    def test_short_default(self):
 
1653
        self.assertFormatterResult(log.ShortLogFormatter, None, """\
 
1654
    1 John Doe\t2005-11-22
 
1655
      add a
 
1656
 
 
1657
""")
 
1658
 
 
1659
    def test_short_committer(self):
 
1660
        self.assertFormatterResult(log.ShortLogFormatter, 'committer', """\
 
1661
    1 Lorem Ipsum\t2005-11-22
 
1662
      add a
 
1663
 
 
1664
""")
 
1665
 
 
1666
    def test_short_first(self):
 
1667
        self.assertFormatterResult(log.ShortLogFormatter, 'first', """\
 
1668
    1 John Doe\t2005-11-22
 
1669
      add a
 
1670
 
 
1671
""")
 
1672
 
 
1673
    def test_short_all(self):
 
1674
        self.assertFormatterResult(log.ShortLogFormatter, 'all', """\
 
1675
    1 John Doe, Jane Rey\t2005-11-22
 
1676
      add a
 
1677
 
 
1678
""")
 
1679
 
 
1680
    def test_long_default(self):
 
1681
        self.assertFormatterResult(log.LongLogFormatter, None, """\
 
1682
------------------------------------------------------------
 
1683
revno: 1
 
1684
author: John Doe <jdoe@example.com>, Jane Rey <jrey@example.com>
 
1685
committer: Lorem Ipsum <test@example.com>
 
1686
branch nick: nicky
 
1687
timestamp: Tue 2005-11-22 00:00:00 +0000
 
1688
message:
 
1689
  add a
 
1690
""")
 
1691
 
 
1692
    def test_long_committer(self):
 
1693
        self.assertFormatterResult(log.LongLogFormatter, 'committer', """\
 
1694
------------------------------------------------------------
 
1695
revno: 1
 
1696
committer: Lorem Ipsum <test@example.com>
 
1697
branch nick: nicky
 
1698
timestamp: Tue 2005-11-22 00:00:00 +0000
 
1699
message:
 
1700
  add a
 
1701
""")
 
1702
 
 
1703
    def test_long_first(self):
 
1704
        self.assertFormatterResult(log.LongLogFormatter, 'first', """\
 
1705
------------------------------------------------------------
 
1706
revno: 1
 
1707
author: John Doe <jdoe@example.com>
 
1708
committer: Lorem Ipsum <test@example.com>
 
1709
branch nick: nicky
 
1710
timestamp: Tue 2005-11-22 00:00:00 +0000
 
1711
message:
 
1712
  add a
 
1713
""")
 
1714
 
 
1715
    def test_long_all(self):
 
1716
        self.assertFormatterResult(log.LongLogFormatter, 'all', """\
 
1717
------------------------------------------------------------
 
1718
revno: 1
 
1719
author: John Doe <jdoe@example.com>, Jane Rey <jrey@example.com>
 
1720
committer: Lorem Ipsum <test@example.com>
 
1721
branch nick: nicky
 
1722
timestamp: Tue 2005-11-22 00:00:00 +0000
 
1723
message:
 
1724
  add a
 
1725
""")
 
1726
 
 
1727
    def test_gnu_changelog_default(self):
 
1728
        self.assertFormatterResult(log.GnuChangelogLogFormatter, None, """\
 
1729
2005-11-22  John Doe  <jdoe@example.com>
 
1730
 
 
1731
\tadd a
 
1732
 
 
1733
""")
 
1734
 
 
1735
    def test_gnu_changelog_committer(self):
 
1736
        self.assertFormatterResult(log.GnuChangelogLogFormatter, 'committer', """\
 
1737
2005-11-22  Lorem Ipsum  <test@example.com>
 
1738
 
 
1739
\tadd a
 
1740
 
 
1741
""")
 
1742
 
 
1743
    def test_gnu_changelog_first(self):
 
1744
        self.assertFormatterResult(log.GnuChangelogLogFormatter, 'first', """\
 
1745
2005-11-22  John Doe  <jdoe@example.com>
 
1746
 
 
1747
\tadd a
 
1748
 
 
1749
""")
 
1750
 
 
1751
    def test_gnu_changelog_all(self):
 
1752
        self.assertFormatterResult(log.GnuChangelogLogFormatter, 'all', """\
 
1753
2005-11-22  John Doe  <jdoe@example.com>, Jane Rey  <jrey@example.com>
 
1754
 
 
1755
\tadd a
 
1756
 
 
1757
""")
 
1758
 
 
1759
 
1546
1760
class TestLogExcludeAncestry(tests.TestCaseWithTransport):
1547
1761
 
1548
1762
    def make_branch_with_alternate_ancestries(self, relpath='.'):
1579
1793
        return br
1580
1794
 
1581
1795
    def assertLogRevnos(self, expected_revnos, b, start, end,
1582
 
                        exclude_common_ancestry):
 
1796
                        exclude_common_ancestry, generate_merge_revisions=True):
1583
1797
        # FIXME: the layering in log makes it hard to test intermediate levels,
1584
1798
        # I wish adding filters with their parameters were easier...
1585
1799
        # -- vila 20100413
1586
1800
        iter_revs = log._calc_view_revisions(
1587
1801
            b, start, end, direction='reverse',
1588
 
            generate_merge_revisions=True,
 
1802
            generate_merge_revisions=generate_merge_revisions,
1589
1803
            exclude_common_ancestry=exclude_common_ancestry)
1590
1804
        self.assertEqual(expected_revnos,
1591
1805
                         [revid for revid, revno, depth in iter_revs])
1593
1807
    def test_merge_sorted_exclude_ancestry(self):
1594
1808
        b = self.make_branch_with_alternate_ancestries()
1595
1809
        self.assertLogRevnos(['3', '1.1.2', '1.2.1', '1.1.1', '2', '1'],
1596
 
                             b, '1', '3', False)
 
1810
                             b, '1', '3', exclude_common_ancestry=False)
1597
1811
        # '2' is part of the '3' ancestry but not part of '1.1.1' ancestry so
1598
1812
        # it should be mentioned even if merge_sort order will make it appear
1599
1813
        # after 1.1.1
1600
1814
        self.assertLogRevnos(['3', '1.1.2', '1.2.1', '2'],
1601
 
                             b, '1.1.1', '3', True)
 
1815
                             b, '1.1.1', '3', exclude_common_ancestry=True)
1602
1816
 
 
1817
    def test_merge_sorted_simple_revnos_exclude_ancestry(self):
 
1818
        b = self.make_branch_with_alternate_ancestries()
 
1819
        self.assertLogRevnos(['3', '2'],
 
1820
                             b, '1', '3', exclude_common_ancestry=True,
 
1821
                             generate_merge_revisions=False)
 
1822
        self.assertLogRevnos(['3', '1.1.2', '1.2.1', '1.1.1', '2'],
 
1823
                             b, '1', '3', exclude_common_ancestry=True,
 
1824
                             generate_merge_revisions=True)
1603
1825