~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Patch Queue Manager
  • Date: 2011-09-22 14:12:18 UTC
  • mfrom: (6155.3.1 jam)
  • Revision ID: pqm@pqm.ubuntu.com-20110922141218-86s4uu6nqvourw4f
(jameinel) Cleanup comments bzrlib/smart/__init__.py (John A Meinel)

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
23
22
 
24
23
from bzrlib import (
25
24
    branchbuilder,
29
28
    tests,
30
29
    )
31
30
from bzrlib.tests import (
32
 
    script,
33
31
    test_log,
 
32
    features,
34
33
    )
35
34
 
36
35
 
77
76
                self.log_catcher = test_log.LogCatcher(*args, **kwargs)
78
77
                # Always return our own log formatter
79
78
                return self.log_catcher
 
79
        # Break cycle with closure over self on cleanup by removing method
 
80
        self.addCleanup(setattr, MyLogFormatter, "__new__", None)
80
81
 
81
82
        def getme(branch):
82
83
                # Always return our own log formatter class hijacking the
88
89
    def get_captured_revisions(self):
89
90
        return self.log_catcher.revisions
90
91
 
91
 
    def assertLogRevnos(self, args, expected_revnos, working_dir='.'):
92
 
        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)
93
98
        self.assertEqual(expected_revnos,
94
99
                         [r.revno for r in self.get_captured_revisions()])
95
100
 
442
447
        self.assertContainsRe(log, r'tags: tag1')
443
448
 
444
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
 
445
469
class TestLogVerbose(TestLog):
446
470
 
447
471
    def setUp(self):
463
487
    def test_log_short_verbose(self):
464
488
        self.assertUseShortDeltaFormat(['log', '--short', '-v'])
465
489
 
 
490
    def test_log_s_verbose(self):
 
491
        self.assertUseShortDeltaFormat(['log', '-S', '-v'])
 
492
 
466
493
    def test_log_short_verbose_verbose(self):
467
494
        self.assertUseLongDeltaFormat(['log', '--short', '-vv'])
468
495
 
513
540
 
514
541
    def test_include_merges(self):
515
542
        # Confirm --include-merges gives the same output as -n0
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')
 
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)
522
552
        out_im, err_im = self.run_bzr('log --include-merges',
523
553
                                      working_dir='level0')
524
554
        out_n0, err_n0 = self.run_bzr('log -n0', working_dir='level0')
525
 
        self.assertEqual('', err_im)
 
555
        self.assertEqual(msg, err_im)
526
556
        self.assertEqual('', err_n0)
527
557
        self.assertEqual(out_im, out_n0)
528
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
 
529
567
    def test_force_merge_revisions_N(self):
530
568
        self.assertLogRevnos(['-n2'],
531
569
                             ['2', '1.1.2', '1.1.1', '1'],
549
587
                [('2', 0), ('1.1.2', 1), ('1.2.1', 2)],
550
588
                working_dir='level0')
551
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
 
552
598
 
553
599
class TestLogDiff(TestLogWithLogCatcher):
554
600
 
924
970
        self.prepare_tree()
925
971
        os.chdir("dir1")
926
972
        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"])