~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_log.py

  • Committer: Robert Collins
  • Date: 2010-05-06 07:48:22 UTC
  • mto: This revision was merged to the branch mainline in revision 5223.
  • Revision ID: robertc@robertcollins.net-20100506074822-0bsgf2j4h8jx0xkk
Added ``bzrlib.tests.matchers`` as a place to put matchers, along with
our first in-tree matcher. See the module docstring for details.
(Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1543
1543
    def test_bugs_handler_present(self):
1544
1544
        self.properties_handler_registry.get('bugs_properties_handler')
1545
1545
 
1546
 
 
1547
 
class TestLogForAuthors(TestCaseForLogFormatter):
1548
 
 
1549
 
    def setUp(self):
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>'])
1554
 
 
1555
 
    def assertFormatterResult(self, formatter, who, result):
1556
 
        formatter_kwargs = dict()
1557
 
        if who is not None:
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)
1562
 
 
1563
 
    def test_line_default(self):
1564
 
        self.assertFormatterResult(log.LineLogFormatter, None, """\
1565
 
1: John Doe 2005-11-22 add a
1566
 
""")
1567
 
 
1568
 
    def test_line_committer(self):
1569
 
        self.assertFormatterResult(log.LineLogFormatter, 'committer', """\
1570
 
1: Lorem Ipsum 2005-11-22 add a
1571
 
""")
1572
 
 
1573
 
    def test_line_first(self):
1574
 
        self.assertFormatterResult(log.LineLogFormatter, 'first', """\
1575
 
1: John Doe 2005-11-22 add a
1576
 
""")
1577
 
 
1578
 
    def test_line_all(self):
1579
 
        self.assertFormatterResult(log.LineLogFormatter, 'all', """\
1580
 
1: John Doe, Jane Rey 2005-11-22 add a
1581
 
""")
1582
 
 
1583
 
 
1584
 
    def test_short_default(self):
1585
 
        self.assertFormatterResult(log.ShortLogFormatter, None, """\
1586
 
    1 John Doe\t2005-11-22
1587
 
      add a
1588
 
 
1589
 
""")
1590
 
 
1591
 
    def test_short_committer(self):
1592
 
        self.assertFormatterResult(log.ShortLogFormatter, 'committer', """\
1593
 
    1 Lorem Ipsum\t2005-11-22
1594
 
      add a
1595
 
 
1596
 
""")
1597
 
 
1598
 
    def test_short_first(self):
1599
 
        self.assertFormatterResult(log.ShortLogFormatter, 'first', """\
1600
 
    1 John Doe\t2005-11-22
1601
 
      add a
1602
 
 
1603
 
""")
1604
 
 
1605
 
    def test_short_all(self):
1606
 
        self.assertFormatterResult(log.ShortLogFormatter, 'all', """\
1607
 
    1 John Doe, Jane Rey\t2005-11-22
1608
 
      add a
1609
 
 
1610
 
""")
1611
 
 
1612
 
    def test_long_default(self):
1613
 
        self.assertFormatterResult(log.LongLogFormatter, None, """\
1614
 
------------------------------------------------------------
1615
 
revno: 1
1616
 
author: John Doe <jdoe@example.com>, Jane Rey <jrey@example.com>
1617
 
committer: Lorem Ipsum <test@example.com>
1618
 
branch nick: nicky
1619
 
timestamp: Tue 2005-11-22 00:00:00 +0000
1620
 
message:
1621
 
  add a
1622
 
""")
1623
 
 
1624
 
    def test_long_committer(self):
1625
 
        self.assertFormatterResult(log.LongLogFormatter, 'committer', """\
1626
 
------------------------------------------------------------
1627
 
revno: 1
1628
 
committer: Lorem Ipsum <test@example.com>
1629
 
branch nick: nicky
1630
 
timestamp: Tue 2005-11-22 00:00:00 +0000
1631
 
message:
1632
 
  add a
1633
 
""")
1634
 
 
1635
 
    def test_long_first(self):
1636
 
        self.assertFormatterResult(log.LongLogFormatter, 'first', """\
1637
 
------------------------------------------------------------
1638
 
revno: 1
1639
 
author: John Doe <jdoe@example.com>
1640
 
committer: Lorem Ipsum <test@example.com>
1641
 
branch nick: nicky
1642
 
timestamp: Tue 2005-11-22 00:00:00 +0000
1643
 
message:
1644
 
  add a
1645
 
""")
1646
 
 
1647
 
    def test_long_all(self):
1648
 
        self.assertFormatterResult(log.LongLogFormatter, 'all', """\
1649
 
------------------------------------------------------------
1650
 
revno: 1
1651
 
author: John Doe <jdoe@example.com>, Jane Rey <jrey@example.com>
1652
 
committer: Lorem Ipsum <test@example.com>
1653
 
branch nick: nicky
1654
 
timestamp: Tue 2005-11-22 00:00:00 +0000
1655
 
message:
1656
 
  add a
1657
 
""")
1658
 
 
1659
 
    def test_gnu_changelog_default(self):
1660
 
        self.assertFormatterResult(log.GnuChangelogLogFormatter, None, """\
1661
 
2005-11-22  John Doe  <jdoe@example.com>
1662
 
 
1663
 
\tadd a
1664
 
 
1665
 
""")
1666
 
 
1667
 
    def test_gnu_changelog_committer(self):
1668
 
        self.assertFormatterResult(log.GnuChangelogLogFormatter, 'committer', """\
1669
 
2005-11-22  Lorem Ipsum  <test@example.com>
1670
 
 
1671
 
\tadd a
1672
 
 
1673
 
""")
1674
 
 
1675
 
    def test_gnu_changelog_first(self):
1676
 
        self.assertFormatterResult(log.GnuChangelogLogFormatter, 'first', """\
1677
 
2005-11-22  John Doe  <jdoe@example.com>
1678
 
 
1679
 
\tadd a
1680
 
 
1681
 
""")
1682
 
 
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>
1686
 
 
1687
 
\tadd a
1688
 
 
1689
 
""")
1690
 
 
1691
1546
class TestLogExcludeAncestry(tests.TestCaseWithTransport):
1692
1547
 
1693
1548
    def make_branch_with_alternate_ancestries(self, relpath='.'):
1724
1579
        return br
1725
1580
 
1726
1581
    def assertLogRevnos(self, expected_revnos, b, start, end,
1727
 
                        exclude_common_ancestry, generate_merge_revisions=True):
 
1582
                        exclude_common_ancestry):
1728
1583
        # FIXME: the layering in log makes it hard to test intermediate levels,
1729
1584
        # I wish adding filters with their parameters were easier...
1730
1585
        # -- vila 20100413
1731
1586
        iter_revs = log._calc_view_revisions(
1732
1587
            b, start, end, direction='reverse',
1733
 
            generate_merge_revisions=generate_merge_revisions,
 
1588
            generate_merge_revisions=True,
1734
1589
            exclude_common_ancestry=exclude_common_ancestry)
1735
1590
        self.assertEqual(expected_revnos,
1736
1591
                         [revid for revid, revno, depth in iter_revs])
1738
1593
    def test_merge_sorted_exclude_ancestry(self):
1739
1594
        b = self.make_branch_with_alternate_ancestries()
1740
1595
        self.assertLogRevnos(['3', '1.1.2', '1.2.1', '1.1.1', '2', '1'],
1741
 
                             b, '1', '3', exclude_common_ancestry=False)
 
1596
                             b, '1', '3', False)
1742
1597
        # '2' is part of the '3' ancestry but not part of '1.1.1' ancestry so
1743
1598
        # it should be mentioned even if merge_sort order will make it appear
1744
1599
        # after 1.1.1
1745
1600
        self.assertLogRevnos(['3', '1.1.2', '1.2.1', '2'],
1746
 
                             b, '1.1.1', '3', exclude_common_ancestry=True)
 
1601
                             b, '1.1.1', '3', True)
1747
1602
 
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)
1756
1603