~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_log.py

  • Committer: Thomi Richards
  • Date: 2011-07-25 02:56:41 UTC
  • mto: This revision was merged to the branch mainline in revision 6049.
  • Revision ID: thomir@gmail.com-20110725025641-nhcw13etp9wlecxn
Fix bug #747958 - 'levels' value is no longer overridden in Logger if the user explicitly asked for less details than the logger is capable of providing.

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
        #wt = self.make_standard_commit('test_default_log_level')
 
1605
        wt = self._prepare_tree_with_merges()
 
1606
        b = wt.branch
 
1607
 
 
1608
        class CustomLogFormatter(log.LogFormatter):
 
1609
            def __init__(self, *args, **kwargs):
 
1610
                super(CustomLogFormatter, self).__init__(*args, **kwargs)
 
1611
                self.revisions = []
 
1612
            def get_levels(self):
 
1613
                # log formatter supports all levels:
 
1614
                return 0
 
1615
            def log_revision(self, revision):
 
1616
                self.revisions.append(revision)
 
1617
 
 
1618
        log_formatter = LogCatcher()
 
1619
        # First request we don't specify number of levels, we should get a
 
1620
        # sensible default (whatever the LogFormatter handles - which in this
 
1621
        # case is 0/everything):
 
1622
        request = log.make_log_request_dict(limit=10)
 
1623
        log.Logger(b, request).show(log_formatter)
 
1624
        # should have all three revisions:
 
1625
        self.assert_(len(log_formatter.revisions) == 3)
 
1626
 
 
1627
        del log_formatter
 
1628
        log_formatter = LogCatcher()
 
1629
        # now explicitly request mainline revisions only:
 
1630
        request = log.make_log_request_dict(limit=10, levels=1)
 
1631
        log.Logger(b, request).show(log_formatter)
 
1632
        # should now only have 2 revisions:
 
1633
        self.assert_(len(log_formatter.revisions) == 2)