~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_log.py

  • Committer: Andrew Bennetts
  • Date: 2010-10-13 00:26:41 UTC
  • mto: This revision was merged to the branch mainline in revision 5498.
  • Revision ID: andrew.bennetts@canonical.com-20101013002641-9tlh9k89mlj1666m
Keep docs-plain working.

Show diffs side-by-side

added added

removed removed

Lines of Context:
117
117
            branch.tags.set_tag('v1.0', 'rev-3')
118
118
        return wt
119
119
 
120
 
 
121
120
class LogCatcher(log.LogFormatter):
122
121
    """Pull log messages into a list rather than displaying them.
123
122
 
372
371
            wt.branch, log.ShortLogFormatter,
373
372
            show_log_kwargs=dict(start_revision=rev, end_revision=rev))
374
373
 
375
 
    def test_show_ids(self):
376
 
        wt = self.make_branch_and_tree('parent')
377
 
        self.build_tree(['parent/f1', 'parent/f2'])
378
 
        wt.add(['f1','f2'])
379
 
        self.wt_commit(wt, 'first post', rev_id='a')
380
 
        child_wt = wt.bzrdir.sprout('child').open_workingtree()
381
 
        self.wt_commit(child_wt, 'branch 1 changes', rev_id='b')
382
 
        wt.merge_from_branch(child_wt.branch)
383
 
        self.wt_commit(wt, 'merge branch 1', rev_id='c')
384
 
        self.assertFormatterResult("""\
385
 
    2 Joe Foo\t2005-11-22 [merge]
386
 
      revision-id:c
387
 
      merge branch 1
388
 
 
389
 
          1.1.1 Joe Foo\t2005-11-22
390
 
                revision-id:b
391
 
                branch 1 changes
392
 
 
393
 
    1 Joe Foo\t2005-11-22
394
 
      revision-id:a
395
 
      first post
396
 
 
397
 
""",
398
 
            wt.branch, log.ShortLogFormatter,
399
 
            formatter_kwargs=dict(levels=0,show_ids=True))
400
 
 
401
374
 
402
375
class TestShortLogFormatterWithMergeRevisions(TestCaseForLogFormatter):
403
376
 
686
659
        self.assertEqualDiff('''custom_prop_name: test_value\n''',
687
660
                             sio.getvalue())
688
661
 
689
 
    def test_show_ids(self):
690
 
        wt = self.make_branch_and_tree('parent')
691
 
        self.build_tree(['parent/f1', 'parent/f2'])
692
 
        wt.add(['f1','f2'])
693
 
        self.wt_commit(wt, 'first post', rev_id='a')
694
 
        child_wt = wt.bzrdir.sprout('child').open_workingtree()
695
 
        self.wt_commit(child_wt, 'branch 1 changes', rev_id='b')
696
 
        wt.merge_from_branch(child_wt.branch)
697
 
        self.wt_commit(wt, 'merge branch 1', rev_id='c')
698
 
        self.assertFormatterResult("""\
699
 
------------------------------------------------------------
700
 
revno: 2 [merge]
701
 
revision-id: c
702
 
parent: a
703
 
parent: b
704
 
committer: Joe Foo <joe@foo.com>
705
 
branch nick: parent
706
 
timestamp: Tue 2005-11-22 00:00:02 +0000
707
 
message:
708
 
  merge branch 1
709
 
    ------------------------------------------------------------
710
 
    revno: 1.1.1
711
 
    revision-id: b
712
 
    parent: a
713
 
    committer: Joe Foo <joe@foo.com>
714
 
    branch nick: child
715
 
    timestamp: Tue 2005-11-22 00:00:01 +0000
716
 
    message:
717
 
      branch 1 changes
718
 
------------------------------------------------------------
719
 
revno: 1
720
 
revision-id: a
721
 
committer: Joe Foo <joe@foo.com>
722
 
branch nick: parent
723
 
timestamp: Tue 2005-11-22 00:00:00 +0000
724
 
message:
725
 
  first post
726
 
""",
727
 
            wt.branch, log.LongLogFormatter,
728
 
            formatter_kwargs=dict(levels=0,show_ids=True))
729
 
 
730
662
 
731
663
class TestLongLogFormatterWithoutMergeRevisions(TestCaseForLogFormatter):
732
664
 
1531
1463
        self.assertNotContainsRe(s.getvalue(), 'Added Revisions:')
1532
1464
 
1533
1465
 
1534
 
class TestRevisionNotInBranch(TestCaseForLogFormatter):
1535
 
 
1536
 
    def setup_a_tree(self):
1537
 
        tree = self.make_branch_and_tree('tree')
1538
 
        tree.lock_write()
1539
 
        self.addCleanup(tree.unlock)
1540
 
        kwargs = {
1541
 
            'committer': 'Joe Foo <joe@foo.com>',
1542
 
            'timestamp': 1132617600, # Mon 2005-11-22 00:00:00 +0000
1543
 
            'timezone': 0, # UTC
1544
 
        }
1545
 
        tree.commit('commit 1a', rev_id='1a', **kwargs)
1546
 
        tree.commit('commit 2a', rev_id='2a', **kwargs)
1547
 
        tree.commit('commit 3a', rev_id='3a', **kwargs)
1548
 
        return tree
1549
 
 
1550
 
    def setup_ab_tree(self):
1551
 
        tree = self.setup_a_tree()
1552
 
        tree.set_last_revision('1a')
1553
 
        tree.branch.set_last_revision_info(1, '1a')
1554
 
        kwargs = {
1555
 
            'committer': 'Joe Foo <joe@foo.com>',
1556
 
            'timestamp': 1132617600, # Mon 2005-11-22 00:00:00 +0000
1557
 
            'timezone': 0, # UTC
1558
 
        }
1559
 
        tree.commit('commit 2b', rev_id='2b', **kwargs)
1560
 
        tree.commit('commit 3b', rev_id='3b', **kwargs)
1561
 
        return tree
1562
 
 
1563
 
    def test_one_revision(self):
1564
 
        tree = self.setup_ab_tree()
1565
 
        lf = LogCatcher()
1566
 
        rev = revisionspec.RevisionInfo(tree.branch, None, '3a')
1567
 
        log.show_log(tree.branch, lf, verbose=True, start_revision=rev,
1568
 
                     end_revision=rev)
1569
 
        self.assertEqual(1, len(lf.revisions))
1570
 
        self.assertEqual(None, lf.revisions[0].revno)   # Out-of-branch
1571
 
        self.assertEqual('3a', lf.revisions[0].rev.revision_id)
1572
 
 
1573
 
    def test_many_revisions(self):
1574
 
        tree = self.setup_ab_tree()
1575
 
        lf = LogCatcher()
1576
 
        start_rev = revisionspec.RevisionInfo(tree.branch, None, '1a')
1577
 
        end_rev = revisionspec.RevisionInfo(tree.branch, None, '3a')
1578
 
        log.show_log(tree.branch, lf, verbose=True, start_revision=start_rev,
1579
 
                     end_revision=end_rev)
1580
 
        self.assertEqual(3, len(lf.revisions))
1581
 
        self.assertEqual(None, lf.revisions[0].revno)   # Out-of-branch
1582
 
        self.assertEqual('3a', lf.revisions[0].rev.revision_id)
1583
 
        self.assertEqual(None, lf.revisions[1].revno)   # Out-of-branch
1584
 
        self.assertEqual('2a', lf.revisions[1].rev.revision_id)
1585
 
        self.assertEqual('1', lf.revisions[2].revno)    # In-branch
1586
 
 
1587
 
    def test_long_format(self):
1588
 
        tree = self.setup_ab_tree()
1589
 
        start_rev = revisionspec.RevisionInfo(tree.branch, None, '1a')
1590
 
        end_rev = revisionspec.RevisionInfo(tree.branch, None, '3a')
1591
 
        self.assertFormatterResult("""\
1592
 
------------------------------------------------------------
1593
 
revision-id: 3a
1594
 
committer: Joe Foo <joe@foo.com>
1595
 
branch nick: tree
1596
 
timestamp: Tue 2005-11-22 00:00:00 +0000
1597
 
message:
1598
 
  commit 3a
1599
 
------------------------------------------------------------
1600
 
revision-id: 2a
1601
 
committer: Joe Foo <joe@foo.com>
1602
 
branch nick: tree
1603
 
timestamp: Tue 2005-11-22 00:00:00 +0000
1604
 
message:
1605
 
  commit 2a
1606
 
------------------------------------------------------------
1607
 
revno: 1
1608
 
committer: Joe Foo <joe@foo.com>
1609
 
branch nick: tree
1610
 
timestamp: Tue 2005-11-22 00:00:00 +0000
1611
 
message:
1612
 
  commit 1a
1613
 
""",
1614
 
            tree.branch, log.LongLogFormatter, show_log_kwargs={
1615
 
                'start_revision': start_rev, 'end_revision': end_rev
1616
 
            })
1617
 
 
1618
 
    def test_short_format(self):
1619
 
        tree = self.setup_ab_tree()
1620
 
        start_rev = revisionspec.RevisionInfo(tree.branch, None, '1a')
1621
 
        end_rev = revisionspec.RevisionInfo(tree.branch, None, '3a')
1622
 
        self.assertFormatterResult("""\
1623
 
      Joe Foo\t2005-11-22
1624
 
      revision-id:3a
1625
 
      commit 3a
1626
 
 
1627
 
      Joe Foo\t2005-11-22
1628
 
      revision-id:2a
1629
 
      commit 2a
1630
 
 
1631
 
    1 Joe Foo\t2005-11-22
1632
 
      commit 1a
1633
 
 
1634
 
""",
1635
 
            tree.branch, log.ShortLogFormatter, show_log_kwargs={
1636
 
                'start_revision': start_rev, 'end_revision': end_rev
1637
 
            })
1638
 
 
1639
 
    def test_line_format(self):
1640
 
        tree = self.setup_ab_tree()
1641
 
        start_rev = revisionspec.RevisionInfo(tree.branch, None, '1a')
1642
 
        end_rev = revisionspec.RevisionInfo(tree.branch, None, '3a')
1643
 
        self.assertFormatterResult("""\
1644
 
Joe Foo 2005-11-22 commit 3a
1645
 
Joe Foo 2005-11-22 commit 2a
1646
 
1: Joe Foo 2005-11-22 commit 1a
1647
 
""",
1648
 
            tree.branch, log.LineLogFormatter, show_log_kwargs={
1649
 
                'start_revision': start_rev, 'end_revision': end_rev
1650
 
            })
1651
 
 
1652
1466
 
1653
1467
class TestLogWithBugs(TestCaseForLogFormatter, TestLogMixin):
1654
1468
 
1874
1688
 
1875
1689
""")
1876
1690
 
1877
 
 
1878
1691
class TestLogExcludeAncestry(tests.TestCaseWithTransport):
1879
1692
 
1880
1693
    def make_branch_with_alternate_ancestries(self, relpath='.'):