46
51
tree.commit(message='message2')
47
52
tree.add('meep.txt')
48
53
tree.commit(message='message3')
49
self.full_log = self.run_bzr(["log", path])[0]
56
def make_merged_branch(self, path='.', format=None):
57
tree = self.make_linear_branch(path, format)
58
tree2 = tree.bzrdir.sprout('tree2',
59
revision_id=tree.branch.get_rev_id(1)).open_workingtree()
60
tree2.commit(message='tree2 message2')
61
tree2.commit(message='tree2 message3')
62
tree.merge_from_branch(tree2.branch)
63
tree.commit(message='merge')
66
def assertRevnos(self, log, must_have=(), must_not_have=()):
67
"""Check if revnos are in or not in the log output"""
68
for revno in must_have:
69
self.assertTrue(('revno: %s\n' % revno) in log,
70
'Does not contain expected revno %s' % revno)
71
for revno in must_not_have:
72
self.assertFalse(('revno: %s\n' % revno) in log,
73
'Contains unexpected revno %s' % revno)
75
def commit_options(self):
76
"""Use some mostly fixed values for commits to simplify tests.
78
Tests can use this function to get some commit attributes. The time
79
stamp is incremented at each commit.
81
self.timestamp += 1 # 1 second between each commit
82
return dict(committer='Lorem Ipsum <joe@foo.com>',
83
timezone=self.timezone,
84
timestamp=self.timestamp,
87
def check_log(self, expected, args, working_dir='level0'):
88
out, err = self.run_bzr(['log', '--timezone', 'utc'] + args,
89
working_dir=working_dir)
90
self.assertEqual('', err)
91
self.assertEqualDiff(expected, test_log.normalize_log(out))
94
class TestLogRevSpecs(TestLog):
52
96
def test_log_null_end_revspec(self):
54
self.assertTrue('revno: 1\n' in self.full_log)
55
self.assertTrue('revno: 2\n' in self.full_log)
56
self.assertTrue('revno: 3\n' in self.full_log)
57
self.assertTrue('message:\n message1\n' in self.full_log)
58
self.assertTrue('message:\n message2\n' in self.full_log)
59
self.assertTrue('message:\n message3\n' in self.full_log)
97
self.make_linear_branch()
98
log = self.run_bzr(['log'])[0]
99
self.assertTrue('revno: 1\n' in log)
100
self.assertTrue('revno: 2\n' in log)
101
self.assertTrue('revno: 3\n' in log)
102
self.assertTrue('message:\n message1\n' in log)
103
self.assertTrue('message:\n message2\n' in log)
104
self.assertTrue('message:\n message3\n' in log)
106
full_log = self.run_bzr(['log'])[0]
61
107
log = self.run_bzr("log -r 1..")[0]
62
self.assertEqualDiff(log, self.full_log)
108
self.assertEqualDiff(log, full_log)
64
110
def test_log_null_begin_revspec(self):
111
self.make_linear_branch()
112
full_log = self.run_bzr(['log'])[0]
66
113
log = self.run_bzr("log -r ..3")[0]
67
self.assertEqualDiff(self.full_log, log)
114
self.assertEqualDiff(full_log, log)
69
116
def test_log_null_both_revspecs(self):
117
self.make_linear_branch()
118
full_log = self.run_bzr(['log'])[0]
71
119
log = self.run_bzr("log -r ..")[0]
72
self.assertEqualDiff(self.full_log, log)
120
self.assertEqualDiff(full_log, log)
74
122
def test_log_zero_revspec(self):
76
self.run_bzr_error('bzr: ERROR: Logging revision 0 is invalid.',
123
self.make_minimal_branch()
124
self.run_bzr_error(['bzr: ERROR: Logging revision 0 is invalid.'],
79
127
def test_log_zero_begin_revspec(self):
81
self.run_bzr_error('bzr: ERROR: Logging revision 0 is invalid.',
128
self.make_linear_branch()
129
self.run_bzr_error(['bzr: ERROR: Logging revision 0 is invalid.'],
82
130
['log', '-r0..2'])
84
132
def test_log_zero_end_revspec(self):
86
self.run_bzr_error('bzr: ERROR: Logging revision 0 is invalid.',
133
self.make_linear_branch()
134
self.run_bzr_error(['bzr: ERROR: Logging revision 0 is invalid.'],
87
135
['log', '-r-2..0'])
89
def test_log_unsupported_timezone(self):
91
self.run_bzr_error('bzr: ERROR: Unsupported timezone format "foo", '
92
'options are "utc", "original", "local".',
93
['log', '--timezone', 'foo'])
95
137
def test_log_negative_begin_revspec_full_log(self):
138
self.make_linear_branch()
139
full_log = self.run_bzr(['log'])[0]
97
140
log = self.run_bzr("log -r -3..")[0]
98
self.assertEqualDiff(self.full_log, log)
141
self.assertEqualDiff(full_log, log)
100
143
def test_log_negative_both_revspec_full_log(self):
144
self.make_linear_branch()
145
full_log = self.run_bzr(['log'])[0]
102
146
log = self.run_bzr("log -r -3..-1")[0]
103
self.assertEqualDiff(self.full_log, log)
147
self.assertEqualDiff(full_log, log)
105
149
def test_log_negative_both_revspec_partial(self):
150
self.make_linear_branch()
107
151
log = self.run_bzr("log -r -3..-2")[0]
108
152
self.assertTrue('revno: 1\n' in log)
109
153
self.assertTrue('revno: 2\n' in log)
110
154
self.assertTrue('revno: 3\n' not in log)
112
156
def test_log_negative_begin_revspec(self):
157
self.make_linear_branch()
114
158
log = self.run_bzr("log -r -2..")[0]
115
159
self.assertTrue('revno: 1\n' not in log)
116
160
self.assertTrue('revno: 2\n' in log)
117
161
self.assertTrue('revno: 3\n' in log)
119
163
def test_log_positive_revspecs(self):
164
self.make_linear_branch()
165
full_log = self.run_bzr(['log'])[0]
121
166
log = self.run_bzr("log -r 1..3")[0]
122
self.assertEqualDiff(self.full_log, log)
167
self.assertEqualDiff(full_log, log)
169
def test_log_dotted_revspecs(self):
170
self.make_merged_branch()
171
log = self.run_bzr("log -n0 -r 1..1.1.1")[0]
172
self.assertRevnos(log, (1, '1.1.1'), (2, 3, '1.1.2', 4))
124
174
def test_log_reversed_revspecs(self):
175
self.make_linear_branch()
126
176
self.run_bzr_error(('bzr: ERROR: Start revision must be older than '
127
177
'the end revision.\n',),
128
178
['log', '-r3..1'])
180
def test_log_reversed_dotted_revspecs(self):
181
self.make_merged_branch()
182
self.run_bzr_error(('bzr: ERROR: Start revision not found in '
183
'left-hand history of end revision.\n',),
130
186
def test_log_revno_n_path(self):
131
self._prepare(path='branch1')
132
self._prepare(path='branch2')
133
log = self.run_bzr("log -r revno:2:branch1..revno:3:branch2",
187
self.make_linear_branch('branch1')
188
self.make_linear_branch('branch2')
190
self.run_bzr("log -r revno:2:branch1..revno:3:branch2", retcode=3)[0]
135
192
log = self.run_bzr("log -r revno:1:branch2..revno:3:branch2")[0]
136
self.assertEqualDiff(self.full_log, log)
193
full_log = self.run_bzr(['log'], working_dir='branch2')[0]
194
self.assertEqualDiff(full_log, log)
137
195
log = self.run_bzr("log -r revno:1:branch2")[0]
138
196
self.assertTrue('revno: 1\n' in log)
139
197
self.assertTrue('revno: 2\n' not in log)
141
199
self.assertTrue('branch nick: branch1\n' not in log)
143
201
def test_log_nonexistent_revno(self):
145
(out, err) = self.run_bzr_error(args="log -r 1234",
146
error_regexes=["bzr: ERROR: Requested revision: '1234' "
147
"does not exist in branch:"])
202
self.make_minimal_branch()
203
(out, err) = self.run_bzr_error(
204
["bzr: ERROR: Requested revision: '1234' "
205
"does not exist in branch:"],
149
208
def test_log_nonexistent_dotted_revno(self):
151
(out, err) = self.run_bzr_error(args="log -r 123.123",
152
error_regexes=["bzr: ERROR: Requested revision: '123.123' "
153
"does not exist in branch:"])
209
self.make_minimal_branch()
210
(out, err) = self.run_bzr_error(
211
["bzr: ERROR: Requested revision: '123.123' "
212
"does not exist in branch:"],
213
['log', '-r123.123'])
155
215
def test_log_change_revno(self):
216
self.make_linear_branch()
157
217
expected_log = self.run_bzr("log -r 1")[0]
158
218
log = self.run_bzr("log -c 1")[0]
159
219
self.assertEqualDiff(expected_log, log)
161
221
def test_log_change_nonexistent_revno(self):
163
(out, err) = self.run_bzr_error(args="log -c 1234",
164
error_regexes=["bzr: ERROR: Requested revision: '1234' "
165
"does not exist in branch:"])
222
self.make_minimal_branch()
223
(out, err) = self.run_bzr_error(
224
["bzr: ERROR: Requested revision: '1234' "
225
"does not exist in branch:"],
167
228
def test_log_change_nonexistent_dotted_revno(self):
169
(out, err) = self.run_bzr_error(args="log -c 123.123",
170
error_regexes=["bzr: ERROR: Requested revision: '123.123' "
171
"does not exist in branch:"])
229
self.make_minimal_branch()
230
(out, err) = self.run_bzr_error(
231
["bzr: ERROR: Requested revision: '123.123' "
232
"does not exist in branch:"],
233
['log', '-c123.123'])
173
def test_log_change_single_revno(self):
175
self.run_bzr_error('bzr: ERROR: Option --change does not'
176
' accept revision ranges',
235
def test_log_change_single_revno_only(self):
236
self.make_minimal_branch()
237
self.run_bzr_error(['bzr: ERROR: Option --change does not'
238
' accept revision ranges'],
177
239
['log', '--change', '2..3'])
179
241
def test_log_change_incompatible_with_revision(self):
181
self.run_bzr_error('bzr: ERROR: --revision and --change'
182
' are mutually exclusive',
242
self.run_bzr_error(['bzr: ERROR: --revision and --change'
243
' are mutually exclusive'],
183
244
['log', '--change', '2', '--revision', '3'])
185
246
def test_log_nonexistent_file(self):
247
self.make_minimal_branch()
186
248
# files that don't exist in either the basis tree or working tree
187
249
# should give an error
188
wt = self.make_branch_and_tree('.')
189
250
out, err = self.run_bzr('log does-not-exist', retcode=3)
190
self.assertContainsRe(
191
err, 'Path unknown at end or start of revision range: does-not-exist')
251
self.assertContainsRe(err,
252
'Path unknown at end or start of revision range: '
193
255
def test_log_with_tags(self):
194
tree = self._prepare(format='dirstate-tags')
256
tree = self.make_linear_branch(format='dirstate-tags')
195
257
branch = tree.branch
196
258
branch.tags.set_tag('tag1', branch.get_rev_id(1))
197
259
branch.tags.set_tag('tag1.1', branch.get_rev_id(1))
282
364
self.assertUseLongDeltaFormat(['log', '--long', '-vv'])
285
class TestLogMerges(TestCaseWithoutPropsHandler):
288
parent_tree = self.make_branch_and_tree('parent')
289
parent_tree.commit(message='first post', allow_pointless=True)
290
child_tree = parent_tree.bzrdir.sprout('child').open_workingtree()
291
child_tree.commit(message='branch 1', allow_pointless=True)
293
child_tree.bzrdir.sprout('smallerchild').open_workingtree()
294
smaller_tree.commit(message='branch 2', allow_pointless=True)
295
child_tree.merge_from_branch(smaller_tree.branch)
296
child_tree.commit(message='merge branch 2')
297
parent_tree.merge_from_branch(child_tree.branch)
298
parent_tree.commit(message='merge branch 1')
301
def _prepare_short(self):
302
parent_tree = self.make_branch_and_tree('parent')
303
parent_tree.commit(message='first post',
304
timestamp=1132586700, timezone=36000,
305
committer='Joe Foo <joe@foo.com>')
306
child_tree = parent_tree.bzrdir.sprout('child').open_workingtree()
307
child_tree.commit(message='branch 1',
308
timestamp=1132586800, timezone=36000,
309
committer='Joe Foo <joe@foo.com>')
311
child_tree.bzrdir.sprout('smallerchild').open_workingtree()
312
smaller_tree.commit(message='branch 2',
313
timestamp=1132586900, timezone=36000,
314
committer='Joe Foo <joe@foo.com>')
315
child_tree.merge_from_branch(smaller_tree.branch)
316
child_tree.commit(message='merge branch 2',
317
timestamp=1132587000, timezone=36000,
318
committer='Joe Foo <joe@foo.com>')
319
parent_tree.merge_from_branch(child_tree.branch)
320
parent_tree.commit(message='merge branch 1',
321
timestamp=1132587100, timezone=36000,
322
committer='Joe Foo <joe@foo.com>')
367
class TestLogMerges(TestLog):
370
super(TestLogMerges, self).setUp()
371
self.make_branches_with_merges()
373
def make_branches_with_merges(self):
374
level0 = self.make_branch_and_tree('level0')
375
level0.commit(message='in branch level0', **self.commit_options())
377
level1 = level0.bzrdir.sprout('level1').open_workingtree()
378
level1.commit(message='in branch level1', **self.commit_options())
380
level2 = level1.bzrdir.sprout('level2').open_workingtree()
381
level2.commit(message='in branch level2', **self.commit_options())
383
level1.merge_from_branch(level2.branch)
384
level1.commit(message='merge branch level2', **self.commit_options())
386
level0.merge_from_branch(level1.branch)
387
level0.commit(message='merge branch level1', **self.commit_options())
325
389
def test_merges_are_indented_by_level(self):
327
out,err = self.run_bzr('log')
328
self.assertEqual('', err)
329
log = normalize_log(out)
330
self.assertEqualDiff(log, """\
331
391
------------------------------------------------------------
333
393
committer: Lorem Ipsum <test@example.com>
335
395
timestamp: Just now
338
398
------------------------------------------------------------
340
400
committer: Lorem Ipsum <test@example.com>
342
402
timestamp: Just now
345
405
------------------------------------------------------------
347
407
committer: Lorem Ipsum <test@example.com>
348
branch nick: smallerchild
349
409
timestamp: Just now
352
412
------------------------------------------------------------
354
414
committer: Lorem Ipsum <test@example.com>
356
416
timestamp: Just now
359
419
------------------------------------------------------------
361
421
committer: Lorem Ipsum <test@example.com>
363
423
timestamp: Just now
427
self.check_log(expected, ['-n0'])
368
429
def test_force_merge_revisions_off(self):
370
out,err = self.run_bzr('log --long -n1')
371
self.assertEqual('', err)
372
log = normalize_log(out)
373
self.assertEqualDiff(log, """\
374
431
------------------------------------------------------------
376
433
committer: Lorem Ipsum <test@example.com>
378
435
timestamp: Just now
381
438
------------------------------------------------------------
383
440
committer: Lorem Ipsum <test@example.com>
385
442
timestamp: Just now
446
self.check_log(expected, ['--long', '-n1'])
390
448
def test_force_merge_revisions_on(self):
391
self._prepare_short()
392
out,err = self.run_bzr('log --short -n0')
393
self.assertEqual('', err)
394
log = normalize_log(out)
395
self.assertEqualDiff(log, """\
396
2 Joe Foo\t2005-11-22 [merge]
399
1.1.2 Joe Foo\t2005-11-22 [merge]
402
1.2.1 Joe Foo\t2005-11-22
405
1.1.1 Joe Foo\t2005-11-22
408
1 Joe Foo\t2005-11-22
450
2 Lorem Ipsum\t2005-11-22 [merge]
453
1.1.2 Lorem Ipsum\t2005-11-22 [merge]
456
1.2.1 Lorem Ipsum\t2005-11-22
459
1.1.1 Lorem Ipsum\t2005-11-22
462
1 Lorem Ipsum\t2005-11-22
466
self.check_log(expected, ['--short', '-n0'])
468
def test_include_merges(self):
469
# Confirm --include-merges gives the same output as -n0
470
out_im, err_im = self.run_bzr('log --include-merges',
471
working_dir='level0')
472
out_n0, err_n0 = self.run_bzr('log -n0', working_dir='level0')
473
self.assertEqual('', err_im)
474
self.assertEqual('', err_n0)
475
self.assertEqual(out_im, out_n0)
413
477
def test_force_merge_revisions_N(self):
414
self._prepare_short()
415
out,err = self.run_bzr('log --short -n2')
416
self.assertEqual('', err)
417
log = normalize_log(out)
418
self.assertEqualDiff(log, """\
419
2 Joe Foo\t2005-11-22 [merge]
422
1.1.2 Joe Foo\t2005-11-22 [merge]
425
1.1.1 Joe Foo\t2005-11-22
428
1 Joe Foo\t2005-11-22
479
2 Lorem Ipsum\t2005-11-22 [merge]
482
1.1.2 Lorem Ipsum\t2005-11-22 [merge]
485
1.1.1 Lorem Ipsum\t2005-11-22
488
1 Lorem Ipsum\t2005-11-22
492
self.check_log(expected, ['--short', '-n2'])
433
494
def test_merges_single_merge_rev(self):
435
out,err = self.run_bzr('log -r1.1.2')
436
self.assertEqual('', err)
437
log = normalize_log(out)
438
self.assertEqualDiff(log, """\
439
496
------------------------------------------------------------
441
498
committer: Lorem Ipsum <test@example.com>
443
500
timestamp: Just now
446
503
------------------------------------------------------------
448
505
committer: Lorem Ipsum <test@example.com>
449
branch nick: smallerchild
450
507
timestamp: Just now
511
self.check_log(expected, ['-n0', '-r1.1.2'])
455
513
def test_merges_partial_range(self):
457
out, err = self.run_bzr('log -r1.1.1..1.1.2')
458
self.assertEqual('', err)
459
log = normalize_log(out)
460
self.assertEqualDiff(log, """\
461
515
------------------------------------------------------------
463
517
committer: Lorem Ipsum <test@example.com>
465
519
timestamp: Just now
468
522
------------------------------------------------------------
470
524
committer: Lorem Ipsum <test@example.com>
471
branch nick: smallerchild
472
526
timestamp: Just now
475
529
------------------------------------------------------------
477
531
committer: Lorem Ipsum <test@example.com>
479
533
timestamp: Just now
484
def test_merges_nonsupporting_formatter(self):
485
# This "feature" of log formatters is madness. If a log
486
# formatter cannot display a dotted-revno, it ought to ignore it.
487
# Otherwise, a linear sequence is always expected to be handled now.
488
raise KnownFailure('log formatters must support linear sequences now')
490
err_msg = 'Selected log formatter only supports mainline revisions.'
491
# The single revision case is tested in the core tests
492
# since all standard formatters support single merge revisions.
493
out,err = self.run_bzr('log --short -r1..1.1.2', retcode=3)
494
self.assertContainsRe(err, err_msg)
495
out,err = self.run_bzr('log --short -r1.1.1..1.1.2', retcode=3)
496
self.assertContainsRe(err, err_msg)
499
def subst_dates(string):
500
"""Replace date strings with constant values."""
501
return re.sub(r'\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2} [-\+]\d{4}',
502
'YYYY-MM-DD HH:MM:SS +ZZZZ', string)
505
class TestLogDiff(TestCaseWithoutPropsHandler):
508
parent_tree = self.make_branch_and_tree('parent')
509
self.build_tree(['parent/file1', 'parent/file2'])
510
parent_tree.add('file1')
511
parent_tree.add('file2')
512
parent_tree.commit(message='first post',
513
timestamp=1132586655, timezone=36000,
514
committer='Lorem Ipsum <test@example.com>')
515
child_tree = parent_tree.bzrdir.sprout('child').open_workingtree()
516
self.build_tree_contents([('child/file2', 'hello\n')])
517
child_tree.commit(message='branch 1',
518
timestamp=1132586700, timezone=36000,
519
committer='Lorem Ipsum <test@example.com>')
520
parent_tree.merge_from_branch(child_tree.branch)
521
parent_tree.commit(message='merge branch 1',
522
timestamp=1132586800, timezone=36000,
523
committer='Lorem Ipsum <test@example.com>')
526
def test_log_show_diff_long(self):
528
out,err = self.run_bzr('log -p')
537
self.check_log(expected, ['-n0', '-r1.1.1..1.1.2'])
540
class TestLogDiff(TestLog):
543
super(TestLogDiff, self).setUp()
544
self.make_branch_with_diffs()
546
def make_branch_with_diffs(self):
547
level0 = self.make_branch_and_tree('level0')
548
self.build_tree(['level0/file1', 'level0/file2'])
551
level0.commit(message='in branch level0', **self.commit_options())
553
level1 = level0.bzrdir.sprout('level1').open_workingtree()
554
self.build_tree_contents([('level1/file2', 'hello\n')])
555
level1.commit(message='in branch level1', **self.commit_options())
556
level0.merge_from_branch(level1.branch)
557
level0.commit(message='merge branch level1', **self.commit_options())
559
def test_log_show_diff_long_with_merges(self):
560
out,err = self.run_bzr('log -p -n0')
529
561
self.assertEqual('', err)
530
log = normalize_log(out)
531
self.assertEqualDiff(subst_dates(log), """\
562
log = test_log.normalize_log(out)
532
564
------------------------------------------------------------
534
566
committer: Lorem Ipsum <test@example.com>
536
568
timestamp: Just now
540
572
=== modified file 'file2'
541
--- file2\tYYYY-MM-DD HH:MM:SS +ZZZZ
542
+++ file2\tYYYY-MM-DD HH:MM:SS +ZZZZ
573
--- file2\t2005-11-22 00:00:01 +0000
574
+++ file2\t2005-11-22 00:00:02 +0000
544
-contents of parent/file2
576
-contents of level0/file2
546
578
------------------------------------------------------------
548
580
committer: Lorem Ipsum <test@example.com>
550
582
timestamp: Just now
554
586
=== modified file 'file2'
555
--- file2\tYYYY-MM-DD HH:MM:SS +ZZZZ
556
+++ file2\tYYYY-MM-DD HH:MM:SS +ZZZZ
587
--- file2\t2005-11-22 00:00:01 +0000
588
+++ file2\t2005-11-22 00:00:02 +0000
558
-contents of parent/file2
590
-contents of level0/file2
560
592
------------------------------------------------------------
562
594
committer: Lorem Ipsum <test@example.com>
564
596
timestamp: Just now
568
600
=== added file 'file1'
569
--- file1\tYYYY-MM-DD HH:MM:SS +ZZZZ
570
+++ file1\tYYYY-MM-DD HH:MM:SS +ZZZZ
601
--- file1\t1970-01-01 00:00:00 +0000
602
+++ file1\t2005-11-22 00:00:01 +0000
572
+contents of parent/file1
604
+contents of level0/file1
574
606
=== added file 'file2'
575
--- file2\tYYYY-MM-DD HH:MM:SS +ZZZZ
576
+++ file2\tYYYY-MM-DD HH:MM:SS +ZZZZ
607
--- file2\t1970-01-01 00:00:00 +0000
608
+++ file2\t2005-11-22 00:00:01 +0000
578
+contents of parent/file2
610
+contents of level0/file2
612
self.check_log(expected, ['-p', '-n0'])
581
614
def test_log_show_diff_short(self):
583
out,err = self.run_bzr('log -p --short')
584
self.assertEqual('', err)
585
log = normalize_log(out)
586
self.assertEqualDiff(subst_dates(log), """\
587
616
2 Lorem Ipsum\t2005-11-22 [merge]
589
618
=== modified file 'file2'
590
--- file2\tYYYY-MM-DD HH:MM:SS +ZZZZ
591
+++ file2\tYYYY-MM-DD HH:MM:SS +ZZZZ
619
--- file2\t2005-11-22 00:00:01 +0000
620
+++ file2\t2005-11-22 00:00:02 +0000
593
-contents of parent/file2
622
-contents of level0/file2
596
625
1 Lorem Ipsum\t2005-11-22
598
627
=== added file 'file1'
599
--- file1\tYYYY-MM-DD HH:MM:SS +ZZZZ
600
+++ file1\tYYYY-MM-DD HH:MM:SS +ZZZZ
628
--- file1\t1970-01-01 00:00:00 +0000
629
+++ file1\t2005-11-22 00:00:01 +0000
602
+contents of parent/file1
631
+contents of level0/file1
603
632
\x20\x20\x20\x20\x20\x20
604
633
=== added file 'file2'
605
--- file2\tYYYY-MM-DD HH:MM:SS +ZZZZ
606
+++ file2\tYYYY-MM-DD HH:MM:SS +ZZZZ
634
--- file2\t1970-01-01 00:00:00 +0000
635
+++ file2\t2005-11-22 00:00:01 +0000
608
+contents of parent/file2
637
+contents of level0/file2
639
Use --include-merges or -n0 to see merged revisions.
641
self.check_log(expected, ['-p', '--short'])
612
643
def test_log_show_diff_line(self):
644
# Not supported by this formatter so expect plain output
646
2: Lorem Ipsum 2005-11-22 [merge] merge branch level1
647
1: Lorem Ipsum 2005-11-22 in branch level0
649
self.check_log(expected, ['-p', '--line'])
651
def test_log_show_diff_file1(self):
652
"""Only the diffs for the given file are to be shown"""
654
1 Lorem Ipsum\t2005-11-22
656
=== added file 'file1'
657
--- file1\t1970-01-01 00:00:00 +0000
658
+++ file1\t2005-11-22 00:00:01 +0000
660
+contents of level0/file1
663
self.check_log(expected, ['-p', '--short', 'file1'])
665
def test_log_show_diff_file2(self):
666
"""Only the diffs for the given file are to be shown"""
668
2 Lorem Ipsum\t2005-11-22 [merge]
670
=== modified file 'file2'
671
--- file2\t2005-11-22 00:00:01 +0000
672
+++ file2\t2005-11-22 00:00:02 +0000
674
-contents of level0/file2
677
1 Lorem Ipsum\t2005-11-22
679
=== added file 'file2'
680
--- file2\t1970-01-01 00:00:00 +0000
681
+++ file2\t2005-11-22 00:00:01 +0000
683
+contents of level0/file2
685
Use --include-merges or -n0 to see merged revisions.
687
self.check_log(expected, ['-p', '--short', 'file2'])
690
class TestLogUnicodeDiff(TestLog):
692
def test_log_show_diff_non_ascii(self):
693
# Smoke test for bug #328007 UnicodeDecodeError on 'log -p'
694
message = u'Message with \xb5'
695
body = 'Body with \xb5\n'
696
wt = self.make_branch_and_tree('.')
697
self.build_tree_contents([('foo', body)])
699
wt.commit(message=message)
700
# check that command won't fail with unicode error
701
# don't care about exact output because we have other tests for this
702
out,err = self.run_bzr('log -p --long')
703
self.assertNotEqual('', out)
704
self.assertEqual('', err)
705
out,err = self.run_bzr('log -p --short')
706
self.assertNotEqual('', out)
707
self.assertEqual('', err)
614
708
out,err = self.run_bzr('log -p --line')
615
self.assertEqual('', err)
616
log = normalize_log(out)
617
# Not supported by this formatter so expect plain output
618
self.assertEqualDiff(subst_dates(log), """\
619
2: Lorem Ipsum 2005-11-22 [merge] merge branch 1
620
1: Lorem Ipsum 2005-11-22 first post
623
def test_log_show_diff_file(self):
624
"""Only the diffs for the given file are to be shown"""
626
out,err = self.run_bzr('log -p --short file2')
627
self.assertEqual('', err)
628
log = normalize_log(out)
629
self.assertEqualDiff(subst_dates(log), """\
630
2 Lorem Ipsum\t2005-11-22 [merge]
632
=== modified file 'file2'
633
--- file2\tYYYY-MM-DD HH:MM:SS +ZZZZ
634
+++ file2\tYYYY-MM-DD HH:MM:SS +ZZZZ
636
-contents of parent/file2
639
1 Lorem Ipsum\t2005-11-22
641
=== added file 'file2'
642
--- file2\tYYYY-MM-DD HH:MM:SS +ZZZZ
643
+++ file2\tYYYY-MM-DD HH:MM:SS +ZZZZ
645
+contents of parent/file2
648
out,err = self.run_bzr('log -p --short file1')
649
self.assertEqual('', err)
650
log = normalize_log(out)
651
self.assertEqualDiff(subst_dates(log), """\
652
1 Lorem Ipsum\t2005-11-22
654
=== added file 'file1'
655
--- file1\tYYYY-MM-DD HH:MM:SS +ZZZZ
656
+++ file1\tYYYY-MM-DD HH:MM:SS +ZZZZ
658
+contents of parent/file1
663
class TestLogEncodings(TestCaseInTempDir):
709
self.assertNotEqual('', out)
710
self.assertEqual('', err)
713
class TestLogEncodings(tests.TestCaseInTempDir):
666
716
_message = u'Message with \xb5'
799
848
def test_log_file(self):
800
849
"""The log for a particular file should only list revs for that file"""
801
850
self.prepare_tree()
802
log = self.run_bzr('log file1')[0]
851
log = self.run_bzr('log -n0 file1')[0]
803
852
self.assertContainsRe(log, 'revno: 1\n')
804
853
self.assertNotContainsRe(log, 'revno: 2\n')
805
854
self.assertNotContainsRe(log, 'revno: 3\n')
806
855
self.assertNotContainsRe(log, 'revno: 3.1.1\n')
807
self.assertNotContainsRe(log, 'revno: 4\n')
808
log = self.run_bzr('log file2')[0]
856
self.assertNotContainsRe(log, 'revno: 4 ')
857
log = self.run_bzr('log -n0 file2')[0]
809
858
self.assertNotContainsRe(log, 'revno: 1\n')
810
859
self.assertContainsRe(log, 'revno: 2\n')
811
860
self.assertNotContainsRe(log, 'revno: 3\n')
812
861
self.assertContainsRe(log, 'revno: 3.1.1\n')
813
self.assertContainsRe(log, 'revno: 4\n')
814
log = self.run_bzr('log file3')[0]
862
self.assertContainsRe(log, 'revno: 4 ')
863
log = self.run_bzr('log -n0 file3')[0]
815
864
self.assertNotContainsRe(log, 'revno: 1\n')
816
865
self.assertNotContainsRe(log, 'revno: 2\n')
817
866
self.assertContainsRe(log, 'revno: 3\n')
818
867
self.assertNotContainsRe(log, 'revno: 3.1.1\n')
819
self.assertNotContainsRe(log, 'revno: 4\n')
820
log = self.run_bzr('log -r3.1.1 file2')[0]
821
self.assertNotContainsRe(log, 'revno: 1\n')
822
self.assertNotContainsRe(log, 'revno: 2\n')
823
self.assertNotContainsRe(log, 'revno: 3\n')
824
self.assertContainsRe(log, 'revno: 3.1.1\n')
825
self.assertNotContainsRe(log, 'revno: 4\n')
826
log = self.run_bzr('log -r4 file2')[0]
827
self.assertNotContainsRe(log, 'revno: 1\n')
828
self.assertNotContainsRe(log, 'revno: 2\n')
829
self.assertNotContainsRe(log, 'revno: 3\n')
830
self.assertContainsRe(log, 'revno: 3.1.1\n')
831
self.assertContainsRe(log, 'revno: 4\n')
832
log = self.run_bzr('log -r3.. file2')[0]
833
self.assertNotContainsRe(log, 'revno: 1\n')
834
self.assertNotContainsRe(log, 'revno: 2\n')
835
self.assertNotContainsRe(log, 'revno: 3\n')
836
self.assertContainsRe(log, 'revno: 3.1.1\n')
837
self.assertContainsRe(log, 'revno: 4\n')
838
log = self.run_bzr('log -r..3 file2')[0]
868
self.assertNotContainsRe(log, 'revno: 4 ')
869
log = self.run_bzr('log -n0 -r3.1.1 file2')[0]
870
self.assertNotContainsRe(log, 'revno: 1\n')
871
self.assertNotContainsRe(log, 'revno: 2\n')
872
self.assertNotContainsRe(log, 'revno: 3\n')
873
self.assertContainsRe(log, 'revno: 3.1.1\n')
874
self.assertNotContainsRe(log, 'revno: 4 ')
875
log = self.run_bzr('log -n0 -r4 file2')[0]
876
self.assertNotContainsRe(log, 'revno: 1\n')
877
self.assertNotContainsRe(log, 'revno: 2\n')
878
self.assertNotContainsRe(log, 'revno: 3\n')
879
self.assertContainsRe(log, 'revno: 3.1.1\n')
880
self.assertContainsRe(log, 'revno: 4 ')
881
log = self.run_bzr('log -n0 -r3.. file2')[0]
882
self.assertNotContainsRe(log, 'revno: 1\n')
883
self.assertNotContainsRe(log, 'revno: 2\n')
884
self.assertNotContainsRe(log, 'revno: 3\n')
885
self.assertContainsRe(log, 'revno: 3.1.1\n')
886
self.assertContainsRe(log, 'revno: 4 ')
887
log = self.run_bzr('log -n0 -r..3 file2')[0]
839
888
self.assertNotContainsRe(log, 'revno: 1\n')
840
889
self.assertContainsRe(log, 'revno: 2\n')
841
890
self.assertNotContainsRe(log, 'revno: 3\n')
842
891
self.assertNotContainsRe(log, 'revno: 3.1.1\n')
843
self.assertNotContainsRe(log, 'revno: 4\n')
892
self.assertNotContainsRe(log, 'revno: 4 ')
845
894
def test_log_file_historical_missing(self):
846
895
# Check logging a deleted file gives an error if the