~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-08-17 18:13:57 UTC
  • mfrom: (5268.7.29 transport-segments)
  • Revision ID: pqm@pqm.ubuntu.com-20110817181357-y5q5eth1hk8bl3om
(jelmer) Allow specifying the colocated branch to use in the branch URL,
 and retrieving the branch name using ControlDir._get_selected_branch.
 (Jelmer Vernooij)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2012, 2016 Canonical Ltd
 
1
# Copyright (C) 2006-2010 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
31
31
    test_log,
32
32
    features,
33
33
    )
34
 
from bzrlib.tests.matchers import ContainsNoVfsCalls
35
34
 
36
35
 
37
36
class TestLog(tests.TestCaseWithTransport, test_log.TestLogMixin):
90
89
    def get_captured_revisions(self):
91
90
        return self.log_catcher.revisions
92
91
 
93
 
    def assertLogRevnos(self, args, expected_revnos, working_dir='.',
94
 
                        out='', err=''):
95
 
        actual_out, actual_err = self.run_bzr(['log'] + args,
96
 
                                              working_dir=working_dir)
97
 
        self.assertEqual(out, actual_out)
98
 
        self.assertEqual(err, actual_err)
 
92
    def assertLogRevnos(self, args, expected_revnos, working_dir='.'):
 
93
        self.run_bzr(['log'] + args, working_dir=working_dir)
99
94
        self.assertEqual(expected_revnos,
100
95
                         [r.revno for r in self.get_captured_revisions()])
101
96
 
205
200
        # 4  1.1.4
206
201
        # | /
207
202
        # 5
208
 
        # | \
209
 
        # | 5.1.1
210
 
        # | /
211
 
        # 6
212
203
 
213
204
        # mainline
214
205
        builder.build_snapshot('1', None, [
227
218
        builder.build_snapshot('1.1.4', ['1.1.3', '4'], [])
228
219
        # merge branch into mainline
229
220
        builder.build_snapshot('5', ['4', '1.1.4'], [])
230
 
        builder.build_snapshot('5.1.1', ['5'], [])
231
 
        builder.build_snapshot('6', ['5', '5.1.1'], [])
232
221
        builder.finish_series()
233
222
 
234
223
    def test_n0(self):
247
236
        self.assertLogRevnos(['-n1', '-r1.1.1..1.1.4', '--forward'],
248
237
                             ['1.1.1', '1.1.2', '1.1.3', '1.1.4'])
249
238
 
250
 
    def test_fallback_when_end_rev_is_not_on_mainline(self):
251
 
        self.assertLogRevnos(['-n1', '-r1.1.1..5.1.1'],
252
 
                             # We don't get 1.1.1 because we say -n1
253
 
                             ['5.1.1', '5', '4', '3'])
254
 
 
255
239
 
256
240
class Test_GenerateAllRevisions(TestLogWithLogCatcher):
257
241
 
269
253
        # The graph below may look a bit complicated (and it may be but I've
270
254
        # banged my head enough on it) but the bug requires at least dotted
271
255
        # revnos *and* merged revisions below that.
272
 
        # 1
273
 
        # | \
274
 
        # 2  1.1.1
275
 
        # | X
276
 
        # 3  2.1.1
277
 
        # |   |    \
278
 
        # |  2.1.2  2.2.1
279
 
        # |   |    X
280
 
        # |  2.1.3  \
281
 
        # | /       /
282
 
        # 4        /
283
 
        # |       /
284
 
        # 5 -----/
285
256
        builder.build_snapshot('1', None, [
286
257
            ('add', ('', 'root-id', 'directory', ''))])
287
258
        builder.build_snapshot('2', ['1'], [])
406
377
    def test_log_reversed_dotted_revspecs(self):
407
378
        self.make_merged_branch()
408
379
        self.run_bzr_error(('bzr: ERROR: Start revision not found in '
409
 
                            'history of end revision.\n',),
 
380
                            'left-hand history of end revision.\n',),
410
381
                           "log -r 1.1.1..1")
411
382
 
412
383
    def test_log_bad_message_re(self):
565
536
 
566
537
    def test_include_merges(self):
567
538
        # Confirm --include-merges gives the same output as -n0
568
 
        msg = ("The option '--include-merges' to 'bzr log' "
569
 
               "has been deprecated in bzr 2.5. "
570
 
               "Please use '--include-merged' instead.\n")
571
 
        self.assertLogRevnos(['--include-merges'],
572
 
                             ['2', '1.1.2', '1.2.1', '1.1.1', '1'],
573
 
                             working_dir='level0', err=msg)
574
 
        self.assertLogRevnos(['--include-merges'],
575
 
                             ['2', '1.1.2', '1.2.1', '1.1.1', '1'],
576
 
                             working_dir='level0', err=msg)
 
539
        self.assertLogRevnos(['--include-merges'],
 
540
                             ['2', '1.1.2', '1.2.1', '1.1.1', '1'],
 
541
                             working_dir='level0')
 
542
        self.assertLogRevnos(['--include-merges'],
 
543
                             ['2', '1.1.2', '1.2.1', '1.1.1', '1'],
 
544
                             working_dir='level0')
577
545
        out_im, err_im = self.run_bzr('log --include-merges',
578
546
                                      working_dir='level0')
579
547
        out_n0, err_n0 = self.run_bzr('log -n0', working_dir='level0')
580
 
        self.assertEqual(msg, err_im)
 
548
        self.assertEqual('', err_im)
581
549
        self.assertEqual('', err_n0)
582
550
        self.assertEqual(out_im, out_n0)
583
551
 
584
 
    def test_include_merged(self):
585
 
        # Confirm --include-merged gives the same output as -n0
586
 
        expected = ['2', '1.1.2', '1.2.1', '1.1.1', '1']
587
 
        self.assertLogRevnos(['--include-merged'],
588
 
                             expected, working_dir='level0')
589
 
        self.assertLogRevnos(['--include-merged'],
590
 
                             expected, working_dir='level0')
591
 
 
592
552
    def test_force_merge_revisions_N(self):
593
553
        self.assertLogRevnos(['-n2'],
594
554
                             ['2', '1.1.2', '1.1.1', '1'],
612
572
                [('2', 0), ('1.1.2', 1), ('1.2.1', 2)],
613
573
                working_dir='level0')
614
574
 
615
 
    def test_omit_merges_with_sidelines(self):
616
 
        self.assertLogRevnos(['--omit-merges', '-n0'], ['1.2.1', '1.1.1', '1'],
617
 
                             working_dir='level0')
618
 
 
619
 
    def test_omit_merges_without_sidelines(self):
620
 
        self.assertLogRevnos(['--omit-merges', '-n1'], ['1'],
621
 
                             working_dir='level0')
622
 
 
623
575
 
624
576
class TestLogDiff(TestLogWithLogCatcher):
625
577
 
837
789
        test_in_cp866 = '\x92\xa5\xe1\xe2'
838
790
        test_in_cp1251 = '\xd2\xe5\xf1\xf2'
839
791
        # Make sure the log string is encoded in cp866
840
 
        self.assertEqual(test_in_cp866, message[2:])
 
792
        self.assertEquals(test_in_cp866, message[2:])
841
793
        # Make sure the cp1251 string is not found anywhere
842
 
        self.assertEqual(-1, stdout.find(test_in_cp1251))
 
794
        self.assertEquals(-1, stdout.find(test_in_cp1251))
843
795
 
844
796
 
845
797
class TestLogFile(TestLogWithLogCatcher):
1018
970
        (stdout, stderr) = self.run_bzr(['log', '-r..2'], retcode=3)
1019
971
        self.assertEqual(["2", "1"],
1020
972
                         [r.revno for r in self.get_captured_revisions()])
1021
 
        self.assertEqual("bzr: ERROR: Further revision history missing.", stderr)
 
973
        self.assertEquals("bzr: ERROR: Further revision history missing.", stderr)
1022
974
 
1023
975
    def test_log_range_open_end(self):
1024
976
        self.assertLogRevnos(["-r1.."], ["2", "1"])
1077
1029
        self.assertLogRevnos(["--match-author", "author"], ["2", "1"])
1078
1030
        self.assertLogRevnos(["--match-author", "author1", 
1079
1031
                              "--match-author", "author2"], ["2", "1"])
1080
 
 
1081
 
 
1082
 
class TestSmartServerLog(tests.TestCaseWithTransport):
1083
 
 
1084
 
    def test_standard_log(self):
1085
 
        self.setup_smart_server_with_call_log()
1086
 
        t = self.make_branch_and_tree('branch')
1087
 
        self.build_tree_contents([('branch/foo', 'thecontents')])
1088
 
        t.add("foo")
1089
 
        t.commit("message")
1090
 
        self.reset_smart_call_log()
1091
 
        out, err = self.run_bzr(['log', self.get_url('branch')])
1092
 
        # This figure represent the amount of work to perform this use case. It
1093
 
        # is entirely ok to reduce this number if a test fails due to rpc_count
1094
 
        # being too low. If rpc_count increases, more network roundtrips have
1095
 
        # become necessary for this use case. Please do not adjust this number
1096
 
        # upwards without agreement from bzr's network support maintainers.
1097
 
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
1098
 
        self.assertLength(1, self.hpss_connections)
1099
 
        self.assertLength(9, self.hpss_calls)
1100
 
 
1101
 
    def test_verbose_log(self):
1102
 
        self.setup_smart_server_with_call_log()
1103
 
        t = self.make_branch_and_tree('branch')
1104
 
        self.build_tree_contents([('branch/foo', 'thecontents')])
1105
 
        t.add("foo")
1106
 
        t.commit("message")
1107
 
        self.reset_smart_call_log()
1108
 
        out, err = self.run_bzr(['log', '-v', self.get_url('branch')])
1109
 
        # This figure represent the amount of work to perform this use case. It
1110
 
        # is entirely ok to reduce this number if a test fails due to rpc_count
1111
 
        # being too low. If rpc_count increases, more network roundtrips have
1112
 
        # become necessary for this use case. Please do not adjust this number
1113
 
        # upwards without agreement from bzr's network support maintainers.
1114
 
        self.assertLength(10, self.hpss_calls)
1115
 
        self.assertLength(1, self.hpss_connections)
1116
 
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
1117
 
 
1118
 
    def test_per_file(self):
1119
 
        self.setup_smart_server_with_call_log()
1120
 
        t = self.make_branch_and_tree('branch')
1121
 
        self.build_tree_contents([('branch/foo', 'thecontents')])
1122
 
        t.add("foo")
1123
 
        t.commit("message")
1124
 
        self.reset_smart_call_log()
1125
 
        out, err = self.run_bzr(['log', '-v', self.get_url('branch') + "/foo"])
1126
 
        # This figure represent the amount of work to perform this use case. It
1127
 
        # is entirely ok to reduce this number if a test fails due to rpc_count
1128
 
        # being too low. If rpc_count increases, more network roundtrips have
1129
 
        # become necessary for this use case. Please do not adjust this number
1130
 
        # upwards without agreement from bzr's network support maintainers.
1131
 
        self.assertLength(14, self.hpss_calls)
1132
 
        self.assertLength(1, self.hpss_connections)
1133
 
        self.assertThat(self.hpss_calls, ContainsNoVfsCalls)