~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: 2010-04-28 09:40:23 UTC
  • mfrom: (5155.1.5 320119-exclude-ancestry)
  • Revision ID: pqm@pqm.ubuntu.com-20100428094023-7504mlou1qk28r9n
(vila) Add --exclude-common-ancestry log option (Vincent Ladeuil)

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,
21
22
    errors,
22
23
    log,
23
24
    registry,
1541
1542
 
1542
1543
    def test_bugs_handler_present(self):
1543
1544
        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