~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-02-27 12:27:33 UTC
  • mto: This revision was merged to the branch mainline in revision 5061.
  • Revision ID: robertc@robertcollins.net-20100227122733-2o3me3fkk3pk36ns
``bzrlib.branchbuilder.BranchBuilder.build_snapshot`` now accepts a
``message_callback`` in the same way that commit does. (Robert Collins)

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
from cStringIO import StringIO
19
19
 
20
20
from bzrlib import (
21
 
    branchbuilder,
22
21
    errors,
23
22
    log,
24
23
    registry,
878
877
            formatter_kwargs=dict(levels=0))
879
878
 
880
879
 
881
 
class TestGnuChangelogFormatter(TestCaseForLogFormatter):
882
 
 
883
 
    def test_gnu_changelog(self):
884
 
        wt = self.make_standard_commit('nicky', authors=[])
885
 
        self.assertFormatterResult('''\
886
 
2005-11-22  Lorem Ipsum  <test@example.com>
887
 
 
888
 
\tadd a
889
 
 
890
 
''',
891
 
            wt.branch, log.GnuChangelogLogFormatter)
892
 
 
893
 
    def test_with_authors(self):
894
 
        wt = self.make_standard_commit('nicky',
895
 
            authors=['Fooa Fooz <foo@example.com>',
896
 
                     'Bari Baro <bar@example.com>'])
897
 
        self.assertFormatterResult('''\
898
 
2005-11-22  Fooa Fooz  <foo@example.com>
899
 
 
900
 
\tadd a
901
 
 
902
 
''',
903
 
            wt.branch, log.GnuChangelogLogFormatter)
904
 
 
905
 
    def test_verbose(self):
906
 
        wt = self.make_standard_commit('nicky')
907
 
        self.assertFormatterResult('''\
908
 
2005-11-22  John Doe  <jdoe@example.com>
909
 
 
910
 
\t* a:
911
 
 
912
 
\tadd a
913
 
 
914
 
''',
915
 
            wt.branch, log.GnuChangelogLogFormatter,
916
 
            show_log_kwargs=dict(verbose=True))
917
 
 
918
880
class TestGetViewRevisions(tests.TestCaseWithTransport, TestLogMixin):
919
881
 
920
882
    def _get_view_revisions(self, *args, **kwargs):
1542
1504
 
1543
1505
    def test_bugs_handler_present(self):
1544
1506
        self.properties_handler_registry.get('bugs_properties_handler')
1545
 
 
1546
 
class TestLogExcludeAncestry(tests.TestCaseWithTransport):
1547
 
 
1548
 
    def make_branch_with_alternate_ancestries(self, relpath='.'):
1549
 
        # See test_merge_sorted_exclude_ancestry below for the difference with
1550
 
        # bt.per_branch.test_iter_merge_sorted_revision.
1551
 
        # TestIterMergeSortedRevisionsBushyGraph. 
1552
 
        # make_branch_with_alternate_ancestries
1553
 
        # and test_merge_sorted_exclude_ancestry
1554
 
        # See the FIXME in assertLogRevnos too.
1555
 
        builder = branchbuilder.BranchBuilder(self.get_transport(relpath))
1556
 
        # 1
1557
 
        # |\
1558
 
        # 2 \
1559
 
        # |  |
1560
 
        # |  1.1.1
1561
 
        # |  | \
1562
 
        # |  |  1.2.1
1563
 
        # |  | /
1564
 
        # |  1.1.2
1565
 
        # | /
1566
 
        # 3
1567
 
        builder.start_series()
1568
 
        builder.build_snapshot('1', None, [
1569
 
            ('add', ('', 'TREE_ROOT', 'directory', '')),])
1570
 
        builder.build_snapshot('1.1.1', ['1'], [])
1571
 
        builder.build_snapshot('2', ['1'], [])
1572
 
        builder.build_snapshot('1.2.1', ['1.1.1'], [])
1573
 
        builder.build_snapshot('1.1.2', ['1.1.1', '1.2.1'], [])
1574
 
        builder.build_snapshot('3', ['2', '1.1.2'], [])
1575
 
        builder.finish_series()
1576
 
        br = builder.get_branch()
1577
 
        br.lock_read()
1578
 
        self.addCleanup(br.unlock)
1579
 
        return br
1580
 
 
1581
 
    def assertLogRevnos(self, expected_revnos, b, start, end,
1582
 
                        exclude_common_ancestry):
1583
 
        # FIXME: the layering in log makes it hard to test intermediate levels,
1584
 
        # I wish adding filters with their parameters were easier...
1585
 
        # -- vila 20100413
1586
 
        iter_revs = log._calc_view_revisions(
1587
 
            b, start, end, direction='reverse',
1588
 
            generate_merge_revisions=True,
1589
 
            exclude_common_ancestry=exclude_common_ancestry)
1590
 
        self.assertEqual(expected_revnos,
1591
 
                         [revid for revid, revno, depth in iter_revs])
1592
 
 
1593
 
    def test_merge_sorted_exclude_ancestry(self):
1594
 
        b = self.make_branch_with_alternate_ancestries()
1595
 
        self.assertLogRevnos(['3', '1.1.2', '1.2.1', '1.1.1', '2', '1'],
1596
 
                             b, '1', '3', False)
1597
 
        # '2' is part of the '3' ancestry but not part of '1.1.1' ancestry so
1598
 
        # it should be mentioned even if merge_sort order will make it appear
1599
 
        # after 1.1.1
1600
 
        self.assertLogRevnos(['3', '1.1.2', '1.2.1', '2'],
1601
 
                             b, '1.1.1', '3', True)
1602
 
 
1603