~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_log.py

Merge direct pack access branch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1531
1531
        self.assertNotContainsRe(s.getvalue(), 'Added Revisions:')
1532
1532
 
1533
1533
 
 
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
 
1534
1652
 
1535
1653
class TestLogWithBugs(TestCaseForLogFormatter, TestLogMixin):
1536
1654