~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_log.py

(gz) Fix test failure on alpha by correcting format string for
 gc_chk_sha1_record (Martin [gz])

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
from itertools import izip
21
21
import os
 
22
import re
22
23
 
23
24
from bzrlib import (
24
25
    branchbuilder,
28
29
    tests,
29
30
    )
30
31
from bzrlib.tests import (
 
32
    script,
31
33
    test_log,
32
 
    features,
33
34
    )
34
35
 
35
36
 
76
77
                self.log_catcher = test_log.LogCatcher(*args, **kwargs)
77
78
                # Always return our own log formatter
78
79
                return self.log_catcher
79
 
        # Break cycle with closure over self on cleanup by removing method
80
 
        self.addCleanup(setattr, MyLogFormatter, "__new__", None)
81
80
 
82
81
        def getme(branch):
83
82
                # Always return our own log formatter class hijacking the
89
88
    def get_captured_revisions(self):
90
89
        return self.log_catcher.revisions
91
90
 
92
 
    def assertLogRevnos(self, args, expected_revnos, working_dir='.',
93
 
                        out='', err=''):
94
 
        actual_out, actual_err = self.run_bzr(['log'] + args,
95
 
                                              working_dir=working_dir)
96
 
        self.assertEqual(out, actual_out)
97
 
        self.assertEqual(err, actual_err)
 
91
    def assertLogRevnos(self, args, expected_revnos, working_dir='.'):
 
92
        self.run_bzr(['log'] + args, working_dir=working_dir)
98
93
        self.assertEqual(expected_revnos,
99
94
                         [r.revno for r in self.get_captured_revisions()])
100
95
 
447
442
        self.assertContainsRe(log, r'tags: tag1')
448
443
 
449
444
 
450
 
class TestLogSignatures(TestLog):
451
 
 
452
 
    def test_log_with_signatures(self):
453
 
        self.requireFeature(features.gpgme)
454
 
 
455
 
        tree = self.make_linear_branch(format='dirstate-tags')
456
 
 
457
 
        log = self.run_bzr("log --signatures")[0]
458
 
        self.assertTrue('signature: no signature' in log)
459
 
 
460
 
    def test_log_without_signatures(self):
461
 
        self.requireFeature(features.gpgme)
462
 
 
463
 
        tree = self.make_linear_branch(format='dirstate-tags')
464
 
 
465
 
        log = self.run_bzr("log")[0]
466
 
        self.assertFalse('signature: no signature' in log)
467
 
 
468
 
 
469
445
class TestLogVerbose(TestLog):
470
446
 
471
447
    def setUp(self):
487
463
    def test_log_short_verbose(self):
488
464
        self.assertUseShortDeltaFormat(['log', '--short', '-v'])
489
465
 
490
 
    def test_log_s_verbose(self):
491
 
        self.assertUseShortDeltaFormat(['log', '-S', '-v'])
492
 
 
493
466
    def test_log_short_verbose_verbose(self):
494
467
        self.assertUseLongDeltaFormat(['log', '--short', '-vv'])
495
468
 
540
513
 
541
514
    def test_include_merges(self):
542
515
        # Confirm --include-merges gives the same output as -n0
543
 
        msg = ("The option '--include-merges' to 'bzr log' "
544
 
               "has been deprecated in bzr 2.5. "
545
 
               "Please use '--include-merged' instead.\n")
546
 
        self.assertLogRevnos(['--include-merges'],
547
 
                             ['2', '1.1.2', '1.2.1', '1.1.1', '1'],
548
 
                             working_dir='level0', err=msg)
549
 
        self.assertLogRevnos(['--include-merges'],
550
 
                             ['2', '1.1.2', '1.2.1', '1.1.1', '1'],
551
 
                             working_dir='level0', err=msg)
 
516
        self.assertLogRevnos(['--include-merges'],
 
517
                             ['2', '1.1.2', '1.2.1', '1.1.1', '1'],
 
518
                             working_dir='level0')
 
519
        self.assertLogRevnos(['--include-merges'],
 
520
                             ['2', '1.1.2', '1.2.1', '1.1.1', '1'],
 
521
                             working_dir='level0')
552
522
        out_im, err_im = self.run_bzr('log --include-merges',
553
523
                                      working_dir='level0')
554
524
        out_n0, err_n0 = self.run_bzr('log -n0', working_dir='level0')
555
 
        self.assertEqual(msg, err_im)
 
525
        self.assertEqual('', err_im)
556
526
        self.assertEqual('', err_n0)
557
527
        self.assertEqual(out_im, out_n0)
558
528
 
559
 
    def test_include_merged(self):
560
 
        # Confirm --include-merged gives the same output as -n0
561
 
        expected = ['2', '1.1.2', '1.2.1', '1.1.1', '1']
562
 
        self.assertLogRevnos(['--include-merged'],
563
 
                             expected, working_dir='level0')
564
 
        self.assertLogRevnos(['--include-merged'],
565
 
                             expected, working_dir='level0')
566
 
 
567
529
    def test_force_merge_revisions_N(self):
568
530
        self.assertLogRevnos(['-n2'],
569
531
                             ['2', '1.1.2', '1.1.1', '1'],
587
549
                [('2', 0), ('1.1.2', 1), ('1.2.1', 2)],
588
550
                working_dir='level0')
589
551
 
590
 
    def test_omit_merges_with_sidelines(self):
591
 
        self.assertLogRevnos(['--omit-merges', '-n0'], ['1.2.1', '1.1.1', '1'],
592
 
                             working_dir='level0')
593
 
 
594
 
    def test_omit_merges_without_sidelines(self):
595
 
        self.assertLogRevnos(['--omit-merges', '-n1'], ['1'],
596
 
                             working_dir='level0')
597
 
 
598
552
 
599
553
class TestLogDiff(TestLogWithLogCatcher):
600
554
 
970
924
        self.prepare_tree()
971
925
        os.chdir("dir1")
972
926
        self.assertLogRevnos(['dir2', 'file5'], ['5', '3'])
973
 
 
974
 
 
975
 
class MainlineGhostTests(TestLogWithLogCatcher):
976
 
 
977
 
    def setUp(self):
978
 
        super(MainlineGhostTests, self).setUp()
979
 
        tree = self.make_branch_and_tree('')
980
 
        tree.set_parent_ids(["spooky"], allow_leftmost_as_ghost=True)
981
 
        tree.add('')
982
 
        tree.commit('msg1', rev_id='rev1')
983
 
        tree.commit('msg2', rev_id='rev2')
984
 
 
985
 
    def test_log_range(self):
986
 
        self.assertLogRevnos(["-r1..2"], ["2", "1"])
987
 
 
988
 
    def test_log_norange(self):
989
 
        self.assertLogRevnos([], ["2", "1"])
990
 
 
991
 
    def test_log_range_open_begin(self):
992
 
        self.knownFailure("log with ghosts fails. bug #726466")
993
 
        (stdout, stderr) = self.run_bzr(['log', '-r..2'], retcode=3)
994
 
        self.assertEqual(["2", "1"],
995
 
                         [r.revno for r in self.get_captured_revisions()])
996
 
        self.assertEquals("bzr: ERROR: Further revision history missing.", stderr)
997
 
 
998
 
    def test_log_range_open_end(self):
999
 
        self.assertLogRevnos(["-r1.."], ["2", "1"])
1000
 
 
1001
 
class TestLogMatch(TestLogWithLogCatcher):
1002
 
    def prepare_tree(self):
1003
 
        tree = self.make_branch_and_tree('')
1004
 
        self.build_tree(
1005
 
            ['/hello.txt', '/goodbye.txt'])
1006
 
        tree.add('hello.txt')
1007
 
        tree.commit(message='message1', committer='committer1', authors=['author1'])
1008
 
        tree.add('goodbye.txt')
1009
 
        tree.commit(message='message2', committer='committer2', authors=['author2'])
1010
 
    
1011
 
    def test_message(self):
1012
 
        self.prepare_tree()
1013
 
        self.assertLogRevnos(["-m", "message1"], ["1"])
1014
 
        self.assertLogRevnos(["-m", "message2"], ["2"])
1015
 
        self.assertLogRevnos(["-m", "message"], ["2", "1"])
1016
 
        self.assertLogRevnos(["-m", "message1", "-m", "message2"], ["2", "1"])
1017
 
        self.assertLogRevnos(["--match-message", "message1"], ["1"])
1018
 
        self.assertLogRevnos(["--match-message", "message2"], ["2"])
1019
 
        self.assertLogRevnos(["--match-message", "message"], ["2", "1"])
1020
 
        self.assertLogRevnos(["--match-message", "message1", 
1021
 
                              "--match-message", "message2"], ["2", "1"])
1022
 
        self.assertLogRevnos(["--message", "message1"], ["1"])
1023
 
        self.assertLogRevnos(["--message", "message2"], ["2"])
1024
 
        self.assertLogRevnos(["--message", "message"], ["2", "1"])
1025
 
        self.assertLogRevnos(["--match-message", "message1", 
1026
 
                              "--message", "message2"], ["2", "1"])
1027
 
        self.assertLogRevnos(["--message", "message1", 
1028
 
                              "--match-message", "message2"], ["2", "1"])
1029
 
 
1030
 
    def test_committer(self):
1031
 
        self.prepare_tree()
1032
 
        self.assertLogRevnos(["-m", "committer1"], ["1"])
1033
 
        self.assertLogRevnos(["-m", "committer2"], ["2"])
1034
 
        self.assertLogRevnos(["-m", "committer"], ["2", "1"])
1035
 
        self.assertLogRevnos(["-m", "committer1", "-m", "committer2"], 
1036
 
                             ["2", "1"])
1037
 
        self.assertLogRevnos(["--match-committer", "committer1"], ["1"])
1038
 
        self.assertLogRevnos(["--match-committer", "committer2"], ["2"])
1039
 
        self.assertLogRevnos(["--match-committer", "committer"], ["2", "1"])
1040
 
        self.assertLogRevnos(["--match-committer", "committer1", 
1041
 
                              "--match-committer", "committer2"], ["2", "1"])
1042
 
 
1043
 
    def test_author(self):
1044
 
        self.prepare_tree()
1045
 
        self.assertLogRevnos(["-m", "author1"], ["1"])
1046
 
        self.assertLogRevnos(["-m", "author2"], ["2"])
1047
 
        self.assertLogRevnos(["-m", "author"], ["2", "1"])
1048
 
        self.assertLogRevnos(["-m", "author1", "-m", "author2"], 
1049
 
                             ["2", "1"])
1050
 
        self.assertLogRevnos(["--match-author", "author1"], ["1"])
1051
 
        self.assertLogRevnos(["--match-author", "author2"], ["2"])
1052
 
        self.assertLogRevnos(["--match-author", "author"], ["2", "1"])
1053
 
        self.assertLogRevnos(["--match-author", "author1", 
1054
 
                              "--match-author", "author2"], ["2", "1"])