~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_log.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-08-03 04:57:59 UTC
  • mfrom: (6042.1.2 fix-log-2)
  • Revision ID: pqm@pqm.ubuntu.com-20110803045759-1lrr8eymve8ofldr
(mbp) Log levels are no longer reset to what the log formatter supports (bug
 747958) (Thomi Richards)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1537
1537
    def make_branch_with_alternate_ancestries(self, relpath='.'):
1538
1538
        # See test_merge_sorted_exclude_ancestry below for the difference with
1539
1539
        # bt.per_branch.test_iter_merge_sorted_revision.
1540
 
        # TestIterMergeSortedRevisionsBushyGraph. 
 
1540
        # TestIterMergeSortedRevisionsBushyGraph.
1541
1541
        # make_branch_with_alternate_ancestries
1542
1542
        # and test_merge_sorted_exclude_ancestry
1543
1543
        # See the FIXME in assertLogRevnos too.
1598
1598
                             b, '1', '3', exclude_common_ancestry=True,
1599
1599
                             generate_merge_revisions=True)
1600
1600
 
 
1601
 
 
1602
class TestLogDefaults(TestCaseForLogFormatter):
 
1603
    def test_default_log_level(self):
 
1604
        """
 
1605
        Test to ensure that specifying 'levels=1' to make_log_request_dict
 
1606
        doesn't get overwritten when using a LogFormatter that supports more
 
1607
        detail.
 
1608
        Fixes bug #747958.
 
1609
        """
 
1610
        wt = self._prepare_tree_with_merges()
 
1611
        b = wt.branch
 
1612
 
 
1613
        class CustomLogFormatter(log.LogFormatter):
 
1614
            def __init__(self, *args, **kwargs):
 
1615
                super(CustomLogFormatter, self).__init__(*args, **kwargs)
 
1616
                self.revisions = []
 
1617
            def get_levels(self):
 
1618
                # log formatter supports all levels:
 
1619
                return 0
 
1620
            def log_revision(self, revision):
 
1621
                self.revisions.append(revision)
 
1622
 
 
1623
        log_formatter = LogCatcher()
 
1624
        # First request we don't specify number of levels, we should get a
 
1625
        # sensible default (whatever the LogFormatter handles - which in this
 
1626
        # case is 0/everything):
 
1627
        request = log.make_log_request_dict(limit=10)
 
1628
        log.Logger(b, request).show(log_formatter)
 
1629
        # should have all three revisions:
 
1630
        self.assertEquals(len(log_formatter.revisions), 3)
 
1631
 
 
1632
        del log_formatter
 
1633
        log_formatter = LogCatcher()
 
1634
        # now explicitly request mainline revisions only:
 
1635
        request = log.make_log_request_dict(limit=10, levels=1)
 
1636
        log.Logger(b, request).show(log_formatter)
 
1637
        # should now only have 2 revisions:
 
1638
        self.assertEquals(len(log_formatter.revisions), 2)