~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

Abbreviate pack_stat struct format to '>6L'

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
    )
30
30
from bzrlib.tests import (
31
31
    test_log,
 
32
    features,
32
33
    )
33
34
 
34
35
 
75
76
                self.log_catcher = test_log.LogCatcher(*args, **kwargs)
76
77
                # Always return our own log formatter
77
78
                return self.log_catcher
 
79
        # Break cycle with closure over self on cleanup by removing method
 
80
        self.addCleanup(setattr, MyLogFormatter, "__new__", None)
78
81
 
79
82
        def getme(branch):
80
83
                # Always return our own log formatter class hijacking the
86
89
    def get_captured_revisions(self):
87
90
        return self.log_catcher.revisions
88
91
 
89
 
    def assertLogRevnos(self, args, expected_revnos, working_dir='.'):
90
 
        self.run_bzr(['log'] + args, working_dir=working_dir)
 
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
98
        self.assertEqual(expected_revnos,
92
99
                         [r.revno for r in self.get_captured_revisions()])
93
100
 
440
447
        self.assertContainsRe(log, r'tags: tag1')
441
448
 
442
449
 
 
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
 
443
469
class TestLogVerbose(TestLog):
444
470
 
445
471
    def setUp(self):
461
487
    def test_log_short_verbose(self):
462
488
        self.assertUseShortDeltaFormat(['log', '--short', '-v'])
463
489
 
 
490
    def test_log_s_verbose(self):
 
491
        self.assertUseShortDeltaFormat(['log', '-S', '-v'])
 
492
 
464
493
    def test_log_short_verbose_verbose(self):
465
494
        self.assertUseLongDeltaFormat(['log', '--short', '-vv'])
466
495
 
511
540
 
512
541
    def test_include_merges(self):
513
542
        # Confirm --include-merges gives the same output as -n0
514
 
        self.assertLogRevnos(['--include-merges'],
515
 
                             ['2', '1.1.2', '1.2.1', '1.1.1', '1'],
516
 
                             working_dir='level0')
517
 
        self.assertLogRevnos(['--include-merges'],
518
 
                             ['2', '1.1.2', '1.2.1', '1.1.1', '1'],
519
 
                             working_dir='level0')
 
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)
520
552
        out_im, err_im = self.run_bzr('log --include-merges',
521
553
                                      working_dir='level0')
522
554
        out_n0, err_n0 = self.run_bzr('log -n0', working_dir='level0')
523
 
        self.assertEqual('', err_im)
 
555
        self.assertEqual(msg, err_im)
524
556
        self.assertEqual('', err_n0)
525
557
        self.assertEqual(out_im, out_n0)
526
558
 
 
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
 
527
567
    def test_force_merge_revisions_N(self):
528
568
        self.assertLogRevnos(['-n2'],
529
569
                             ['2', '1.1.2', '1.1.1', '1'],
547
587
                [('2', 0), ('1.1.2', 1), ('1.2.1', 2)],
548
588
                working_dir='level0')
549
589
 
 
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
 
550
598
 
551
599
class TestLogDiff(TestLogWithLogCatcher):
552
600
 
941
989
        self.assertLogRevnos([], ["2", "1"])
942
990
 
943
991
    def test_log_range_open_begin(self):
944
 
        raise tests.KnownFailure("log with ghosts fails. bug #726466")
 
992
        self.knownFailure("log with ghosts fails. bug #726466")
945
993
        (stdout, stderr) = self.run_bzr(['log', '-r..2'], retcode=3)
946
994
        self.assertEqual(["2", "1"],
947
995
                         [r.revno for r in self.get_captured_revisions()])
949
997
 
950
998
    def test_log_range_open_end(self):
951
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"])