61
40
log.properties_handler_registry = self.properties_handler_registry
62
41
self.addCleanup(restore)
64
def assertFormatterResult(self, result, branch, formatter_class,
65
formatter_kwargs=None, show_log_kwargs=None):
66
logfile = self.make_utf8_encoded_stringio()
67
if formatter_kwargs is None:
69
formatter = formatter_class(to_file=logfile, **formatter_kwargs)
70
if show_log_kwargs is None:
72
log.show_log(branch, formatter, **show_log_kwargs)
73
self.assertEqualDiff(result, logfile.getvalue())
75
def make_standard_commit(self, branch_nick, **kwargs):
76
wt = self.make_branch_and_tree('.')
78
self.addCleanup(wt.unlock)
79
self.build_tree(['a'])
81
wt.branch.nick = branch_nick
82
kwargs.setdefault('committer', 'Lorem Ipsum <test@example.com>')
83
kwargs.setdefault('authors', ['John Doe <jdoe@example.com>'])
84
self.wt_commit(wt, 'add a', **kwargs)
87
def make_commits_with_trailing_newlines(self, wt):
88
"""Helper method for LogFormatter tests"""
91
self.build_tree_contents([('a', 'hello moto\n')])
92
self.wt_commit(wt, 'simple log message', rev_id='a1')
93
self.build_tree_contents([('b', 'goodbye\n')])
95
self.wt_commit(wt, 'multiline\nlog\nmessage\n', rev_id='a2')
97
self.build_tree_contents([('c', 'just another manic monday\n')])
99
self.wt_commit(wt, 'single line with trailing newline\n', rev_id='a3')
102
def _prepare_tree_with_merges(self, with_tags=False):
103
wt = self.make_branch_and_memory_tree('.')
105
self.addCleanup(wt.unlock)
107
self.wt_commit(wt, 'rev-1', rev_id='rev-1')
108
self.wt_commit(wt, 'rev-merged', rev_id='rev-2a')
109
wt.set_parent_ids(['rev-1', 'rev-2a'])
110
wt.branch.set_last_revision_info(1, 'rev-1')
111
self.wt_commit(wt, 'rev-2', rev_id='rev-2b')
114
branch.tags.set_tag('v0.2', 'rev-2b')
115
self.wt_commit(wt, 'rev-3', rev_id='rev-3')
116
branch.tags.set_tag('v1.0rc1', 'rev-3')
117
branch.tags.set_tag('v1.0', 'rev-3')
120
44
class LogCatcher(log.LogFormatter):
121
45
"""Pull log messages into a list rather than displaying them.
281
201
self.checkDelta(logentry.delta, added=['file1', 'file2'])
284
class TestShortLogFormatter(TestCaseForLogFormatter):
204
def make_commits_with_trailing_newlines(wt):
205
"""Helper method for LogFormatter tests"""
208
open('a', 'wb').write('hello moto\n')
210
wt.commit('simple log message', rev_id='a1',
211
timestamp=1132586655.459960938, timezone=-6*3600,
212
committer='Joe Foo <joe@foo.com>')
213
open('b', 'wb').write('goodbye\n')
215
wt.commit('multiline\nlog\nmessage\n', rev_id='a2',
216
timestamp=1132586842.411175966, timezone=-6*3600,
217
committer='Joe Foo <joe@foo.com>',
218
authors=['Joe Bar <joe@bar.com>'])
220
open('c', 'wb').write('just another manic monday\n')
222
wt.commit('single line with trailing newline\n', rev_id='a3',
223
timestamp=1132587176.835228920, timezone=-6*3600,
224
committer = 'Joe Foo <joe@foo.com>')
228
def normalize_log(log):
229
"""Replaces the variable lines of logs with fixed lines"""
230
author = 'author: Dolor Sit <test@example.com>'
231
committer = 'committer: Lorem Ipsum <test@example.com>'
232
lines = log.splitlines(True)
233
for idx,line in enumerate(lines):
234
stripped_line = line.lstrip()
235
indent = ' ' * (len(line) - len(stripped_line))
236
if stripped_line.startswith('author:'):
237
lines[idx] = indent + author + '\n'
238
elif stripped_line.startswith('committer:'):
239
lines[idx] = indent + committer + '\n'
240
elif stripped_line.startswith('timestamp:'):
241
lines[idx] = indent + 'timestamp: Just now\n'
242
return ''.join(lines)
245
class TestShortLogFormatter(tests.TestCaseWithTransport):
286
247
def test_trailing_newlines(self):
287
248
wt = self.make_branch_and_tree('.')
288
b = self.make_commits_with_trailing_newlines(wt)
289
self.assertFormatterResult("""\
290
3 Joe Foo\t2005-11-22
249
b = make_commits_with_trailing_newlines(wt)
250
sio = self.make_utf8_encoded_stringio()
251
lf = log.ShortLogFormatter(to_file=sio)
253
self.assertEqualDiff("""\
254
3 Joe Foo\t2005-11-21
291
255
single line with trailing newline
293
2 Joe Foo\t2005-11-22
257
2 Joe Bar\t2005-11-21
298
1 Joe Foo\t2005-11-22
262
1 Joe Foo\t2005-11-21
299
263
simple log message
302
b, log.ShortLogFormatter)
268
def _prepare_tree_with_merges(self, with_tags=False):
269
wt = self.make_branch_and_memory_tree('.')
271
self.addCleanup(wt.unlock)
273
wt.commit('rev-1', rev_id='rev-1',
274
timestamp=1132586655, timezone=36000,
275
committer='Joe Foo <joe@foo.com>')
276
wt.commit('rev-merged', rev_id='rev-2a',
277
timestamp=1132586700, timezone=36000,
278
committer='Joe Foo <joe@foo.com>')
279
wt.set_parent_ids(['rev-1', 'rev-2a'])
280
wt.branch.set_last_revision_info(1, 'rev-1')
281
wt.commit('rev-2', rev_id='rev-2b',
282
timestamp=1132586800, timezone=36000,
283
committer='Joe Foo <joe@foo.com>')
286
branch.tags.set_tag('v0.2', 'rev-2b')
287
wt.commit('rev-3', rev_id='rev-3',
288
timestamp=1132586900, timezone=36000,
289
committer='Jane Foo <jane@foo.com>')
290
branch.tags.set_tag('v1.0rc1', 'rev-3')
291
branch.tags.set_tag('v1.0', 'rev-3')
304
294
def test_short_log_with_merges(self):
305
295
wt = self._prepare_tree_with_merges()
306
self.assertFormatterResult("""\
296
logfile = self.make_utf8_encoded_stringio()
297
formatter = log.ShortLogFormatter(to_file=logfile)
298
log.show_log(wt.branch, formatter)
299
self.assertEqualDiff("""\
307
300
2 Joe Foo\t2005-11-22 [merge]
325
322
Use --include-merges or -n0 to see merged revisions.
327
wt.branch, log.ShortLogFormatter,
328
formatter_kwargs=dict(show_advice=True))
330
326
def test_short_log_with_merges_and_range(self):
331
wt = self._prepare_tree_with_merges()
332
self.wt_commit(wt, 'rev-3a', rev_id='rev-3a')
327
wt = self.make_branch_and_memory_tree('.')
329
self.addCleanup(wt.unlock)
331
wt.commit('rev-1', rev_id='rev-1',
332
timestamp=1132586655, timezone=36000,
333
committer='Joe Foo <joe@foo.com>')
334
wt.commit('rev-merged', rev_id='rev-2a',
335
timestamp=1132586700, timezone=36000,
336
committer='Joe Foo <joe@foo.com>')
337
wt.branch.set_last_revision_info(1, 'rev-1')
338
wt.set_parent_ids(['rev-1', 'rev-2a'])
339
wt.commit('rev-2b', rev_id='rev-2b',
340
timestamp=1132586800, timezone=36000,
341
committer='Joe Foo <joe@foo.com>')
342
wt.commit('rev-3a', rev_id='rev-3a',
343
timestamp=1132586800, timezone=36000,
344
committer='Joe Foo <joe@foo.com>')
333
345
wt.branch.set_last_revision_info(2, 'rev-2b')
334
346
wt.set_parent_ids(['rev-2b', 'rev-3a'])
335
self.wt_commit(wt, 'rev-3b', rev_id='rev-3b')
336
self.assertFormatterResult("""\
347
wt.commit('rev-3b', rev_id='rev-3b',
348
timestamp=1132586800, timezone=36000,
349
committer='Joe Foo <joe@foo.com>')
350
logfile = self.make_utf8_encoded_stringio()
351
formatter = log.ShortLogFormatter(to_file=logfile)
352
log.show_log(wt.branch, formatter,
353
start_revision=2, end_revision=3)
354
self.assertEqualDiff("""\
337
355
3 Joe Foo\t2005-11-22 [merge]
340
358
2 Joe Foo\t2005-11-22 [merge]
344
wt.branch, log.ShortLogFormatter,
345
show_log_kwargs=dict(start_revision=2, end_revision=3))
347
364
def test_short_log_with_tags(self):
348
365
wt = self._prepare_tree_with_merges(with_tags=True)
349
self.assertFormatterResult("""\
350
3 Joe Foo\t2005-11-22 {v1.0, v1.0rc1}
366
logfile = self.make_utf8_encoded_stringio()
367
formatter = log.ShortLogFormatter(to_file=logfile)
368
log.show_log(wt.branch, formatter)
369
self.assertEqualDiff("""\
370
3 Jane Foo\t2005-11-22 {v1.0, v1.0rc1}
353
373
2 Joe Foo\t2005-11-22 {v0.2} [merge]
360
wt.branch, log.ShortLogFormatter)
362
382
def test_short_log_single_merge_revision(self):
363
wt = self._prepare_tree_with_merges()
383
wt = self.make_branch_and_memory_tree('.')
385
self.addCleanup(wt.unlock)
387
wt.commit('rev-1', rev_id='rev-1',
388
timestamp=1132586655, timezone=36000,
389
committer='Joe Foo <joe@foo.com>')
390
wt.commit('rev-merged', rev_id='rev-2a',
391
timestamp=1132586700, timezone=36000,
392
committer='Joe Foo <joe@foo.com>')
393
wt.set_parent_ids(['rev-1', 'rev-2a'])
394
wt.branch.set_last_revision_info(1, 'rev-1')
395
wt.commit('rev-2', rev_id='rev-2b',
396
timestamp=1132586800, timezone=36000,
397
committer='Joe Foo <joe@foo.com>')
398
logfile = self.make_utf8_encoded_stringio()
399
formatter = log.ShortLogFormatter(to_file=logfile)
364
400
revspec = revisionspec.RevisionSpec.from_string('1.1.1')
365
rev = revspec.in_history(wt.branch)
366
self.assertFormatterResult("""\
402
rev = revspec.in_history(wtb)
403
log.show_log(wtb, formatter, start_revision=rev, end_revision=rev)
404
self.assertEqualDiff("""\
367
405
1.1.1 Joe Foo\t2005-11-22
371
wt.branch, log.ShortLogFormatter,
372
show_log_kwargs=dict(start_revision=rev, end_revision=rev))
375
class TestShortLogFormatterWithMergeRevisions(TestCaseForLogFormatter):
412
class TestShortLogFormatterWithMergeRevisions(tests.TestCaseWithTransport):
377
414
def test_short_merge_revs_log_with_merges(self):
378
wt = self._prepare_tree_with_merges()
415
wt = self.make_branch_and_memory_tree('.')
417
self.addCleanup(wt.unlock)
419
wt.commit('rev-1', rev_id='rev-1',
420
timestamp=1132586655, timezone=36000,
421
committer='Joe Foo <joe@foo.com>')
422
wt.commit('rev-merged', rev_id='rev-2a',
423
timestamp=1132586700, timezone=36000,
424
committer='Joe Foo <joe@foo.com>')
425
wt.set_parent_ids(['rev-1', 'rev-2a'])
426
wt.branch.set_last_revision_info(1, 'rev-1')
427
wt.commit('rev-2', rev_id='rev-2b',
428
timestamp=1132586800, timezone=36000,
429
committer='Joe Foo <joe@foo.com>')
430
logfile = self.make_utf8_encoded_stringio()
431
formatter = log.ShortLogFormatter(to_file=logfile, levels=0)
432
log.show_log(wt.branch, formatter)
379
433
# Note that the 1.1.1 indenting is in fact correct given that
380
434
# the revision numbers are right justified within 5 characters
381
435
# for mainline revnos and 9 characters for dotted revnos.
382
self.assertFormatterResult("""\
436
self.assertEqualDiff("""\
383
437
2 Joe Foo\t2005-11-22 [merge]
393
wt.branch, log.ShortLogFormatter,
394
formatter_kwargs=dict(levels=0))
396
449
def test_short_merge_revs_log_single_merge_revision(self):
397
wt = self._prepare_tree_with_merges()
450
wt = self.make_branch_and_memory_tree('.')
452
self.addCleanup(wt.unlock)
454
wt.commit('rev-1', rev_id='rev-1',
455
timestamp=1132586655, timezone=36000,
456
committer='Joe Foo <joe@foo.com>')
457
wt.commit('rev-merged', rev_id='rev-2a',
458
timestamp=1132586700, timezone=36000,
459
committer='Joe Foo <joe@foo.com>')
460
wt.set_parent_ids(['rev-1', 'rev-2a'])
461
wt.branch.set_last_revision_info(1, 'rev-1')
462
wt.commit('rev-2', rev_id='rev-2b',
463
timestamp=1132586800, timezone=36000,
464
committer='Joe Foo <joe@foo.com>')
465
logfile = self.make_utf8_encoded_stringio()
466
formatter = log.ShortLogFormatter(to_file=logfile, levels=0)
398
467
revspec = revisionspec.RevisionSpec.from_string('1.1.1')
399
rev = revspec.in_history(wt.branch)
400
self.assertFormatterResult("""\
469
rev = revspec.in_history(wtb)
470
log.show_log(wtb, formatter, start_revision=rev, end_revision=rev)
471
self.assertEqualDiff("""\
401
472
1.1.1 Joe Foo\t2005-11-22
405
wt.branch, log.ShortLogFormatter,
406
formatter_kwargs=dict(levels=0),
407
show_log_kwargs=dict(start_revision=rev, end_revision=rev))
410
class TestLongLogFormatter(TestCaseForLogFormatter):
479
class TestLongLogFormatter(TestCaseWithoutPropsHandler):
412
481
def test_verbose_log(self):
413
482
"""Verbose log includes changed files
417
wt = self.make_standard_commit('test_verbose_log', authors=[])
418
self.assertFormatterResult('''\
486
wt = self.make_branch_and_tree('.')
488
self.build_tree(['a'])
490
# XXX: why does a longer nick show up?
491
b.nick = 'test_verbose_log'
492
wt.commit(message='add a',
493
timestamp=1132711707,
495
committer='Lorem Ipsum <test@example.com>')
496
logfile = file('out.tmp', 'w+')
497
formatter = log.LongLogFormatter(to_file=logfile)
498
log.show_log(b, formatter, verbose=True)
501
log_contents = logfile.read()
502
self.assertEqualDiff('''\
419
503
------------------------------------------------------------
421
505
committer: Lorem Ipsum <test@example.com>
422
506
branch nick: test_verbose_log
423
timestamp: Tue 2005-11-22 00:00:00 +0000
507
timestamp: Wed 2005-11-23 12:08:27 +1000
429
wt.branch, log.LongLogFormatter,
430
show_log_kwargs=dict(verbose=True))
432
515
def test_merges_are_indented_by_level(self):
433
516
wt = self.make_branch_and_tree('parent')
434
self.wt_commit(wt, 'first post')
435
child_wt = wt.bzrdir.sprout('child').open_workingtree()
436
self.wt_commit(child_wt, 'branch 1')
437
smallerchild_wt = wt.bzrdir.sprout('smallerchild').open_workingtree()
438
self.wt_commit(smallerchild_wt, 'branch 2')
439
child_wt.merge_from_branch(smallerchild_wt.branch)
440
self.wt_commit(child_wt, 'merge branch 2')
441
wt.merge_from_branch(child_wt.branch)
442
self.wt_commit(wt, 'merge branch 1')
443
self.assertFormatterResult("""\
517
wt.commit('first post')
518
self.run_bzr('branch parent child')
519
self.run_bzr(['commit', '-m', 'branch 1', '--unchanged', 'child'])
520
self.run_bzr('branch child smallerchild')
521
self.run_bzr(['commit', '-m', 'branch 2', '--unchanged',
524
self.run_bzr('merge ../smallerchild')
525
self.run_bzr(['commit', '-m', 'merge branch 2'])
526
os.chdir('../parent')
527
self.run_bzr('merge ../child')
528
wt.commit('merge branch 1')
530
sio = self.make_utf8_encoded_stringio()
531
lf = log.LongLogFormatter(to_file=sio, levels=0)
532
log.show_log(b, lf, verbose=True)
533
the_log = normalize_log(sio.getvalue())
534
self.assertEqualDiff("""\
444
535
------------------------------------------------------------
446
committer: Joe Foo <joe@foo.com>
537
committer: Lorem Ipsum <test@example.com>
447
538
branch nick: parent
448
timestamp: Tue 2005-11-22 00:00:04 +0000
451
542
------------------------------------------------------------
452
543
revno: 1.1.2 [merge]
453
committer: Joe Foo <joe@foo.com>
544
committer: Lorem Ipsum <test@example.com>
454
545
branch nick: child
455
timestamp: Tue 2005-11-22 00:00:03 +0000
458
549
------------------------------------------------------------
460
committer: Joe Foo <joe@foo.com>
551
committer: Lorem Ipsum <test@example.com>
461
552
branch nick: smallerchild
462
timestamp: Tue 2005-11-22 00:00:02 +0000
465
556
------------------------------------------------------------
467
committer: Joe Foo <joe@foo.com>
558
committer: Lorem Ipsum <test@example.com>
468
559
branch nick: child
469
timestamp: Tue 2005-11-22 00:00:01 +0000
472
563
------------------------------------------------------------
474
committer: Joe Foo <joe@foo.com>
565
committer: Lorem Ipsum <test@example.com>
475
566
branch nick: parent
476
timestamp: Tue 2005-11-22 00:00:00 +0000
480
wt.branch, log.LongLogFormatter,
481
formatter_kwargs=dict(levels=0),
482
show_log_kwargs=dict(verbose=True))
484
573
def test_verbose_merge_revisions_contain_deltas(self):
485
574
wt = self.make_branch_and_tree('parent')
486
575
self.build_tree(['parent/f1', 'parent/f2'])
487
576
wt.add(['f1','f2'])
488
self.wt_commit(wt, 'first post')
489
child_wt = wt.bzrdir.sprout('child').open_workingtree()
577
wt.commit('first post')
578
self.run_bzr('branch parent child')
490
579
os.unlink('child/f1')
491
self.build_tree_contents([('child/f2', 'hello\n')])
492
self.wt_commit(child_wt, 'removed f1 and modified f2')
493
wt.merge_from_branch(child_wt.branch)
494
self.wt_commit(wt, 'merge branch 1')
495
self.assertFormatterResult("""\
580
file('child/f2', 'wb').write('hello\n')
581
self.run_bzr(['commit', '-m', 'removed f1 and modified f2',
584
self.run_bzr('merge ../child')
585
wt.commit('merge branch 1')
587
sio = self.make_utf8_encoded_stringio()
588
lf = log.LongLogFormatter(to_file=sio, levels=0)
589
log.show_log(b, lf, verbose=True)
590
the_log = normalize_log(sio.getvalue())
591
self.assertEqualDiff("""\
496
592
------------------------------------------------------------
498
committer: Joe Foo <joe@foo.com>
594
committer: Lorem Ipsum <test@example.com>
499
595
branch nick: parent
500
timestamp: Tue 2005-11-22 00:00:02 +0000
555
653
committer: Joe Foo <joe@foo.com>
556
654
branch nick: test
557
timestamp: Tue 2005-11-22 00:00:00 +0000
655
timestamp: Mon 2005-11-21 09:24:15 -0600
559
657
simple log message
561
b, log.LongLogFormatter)
563
661
def test_author_in_log(self):
564
662
"""Log includes the author name if it's set in
565
663
the revision properties
567
wt = self.make_standard_commit('test_author_log',
568
authors=['John Doe <jdoe@example.com>',
569
'Jane Rey <jrey@example.com>'])
570
self.assertFormatterResult("""\
665
wt = self.make_branch_and_tree('.')
667
self.build_tree(['a'])
669
b.nick = 'test_author_log'
670
wt.commit(message='add a',
671
timestamp=1132711707,
673
committer='Lorem Ipsum <test@example.com>',
674
authors=['John Doe <jdoe@example.com>',
675
'Jane Rey <jrey@example.com>'])
677
formatter = log.LongLogFormatter(to_file=sio)
678
log.show_log(b, formatter)
679
self.assertEqualDiff('''\
571
680
------------------------------------------------------------
573
682
author: John Doe <jdoe@example.com>, Jane Rey <jrey@example.com>
574
683
committer: Lorem Ipsum <test@example.com>
575
684
branch nick: test_author_log
576
timestamp: Tue 2005-11-22 00:00:00 +0000
685
timestamp: Wed 2005-11-23 12:08:27 +1000
580
wt.branch, log.LongLogFormatter)
582
691
def test_properties_in_log(self):
583
692
"""Log includes the custom properties returned by the registered
586
wt = self.make_standard_commit('test_properties_in_log')
587
def trivial_custom_prop_handler(revision):
588
return {'test_prop':'test_value'}
695
wt = self.make_branch_and_tree('.')
697
self.build_tree(['a'])
699
b.nick = 'test_properties_in_log'
700
wt.commit(message='add a',
701
timestamp=1132711707,
703
committer='Lorem Ipsum <test@example.com>',
704
authors=['John Doe <jdoe@example.com>'])
706
formatter = log.LongLogFormatter(to_file=sio)
708
def trivial_custom_prop_handler(revision):
709
return {'test_prop':'test_value'}
590
# Cleaned up in setUp()
591
log.properties_handler_registry.register(
592
'trivial_custom_prop_handler',
593
trivial_custom_prop_handler)
594
self.assertFormatterResult("""\
711
log.properties_handler_registry.register(
712
'trivial_custom_prop_handler',
713
trivial_custom_prop_handler)
714
log.show_log(b, formatter)
716
log.properties_handler_registry.remove(
717
'trivial_custom_prop_handler')
718
self.assertEqualDiff('''\
595
719
------------------------------------------------------------
597
721
test_prop: test_value
598
722
author: John Doe <jdoe@example.com>
599
723
committer: Lorem Ipsum <test@example.com>
600
724
branch nick: test_properties_in_log
601
timestamp: Tue 2005-11-22 00:00:00 +0000
725
timestamp: Wed 2005-11-23 12:08:27 +1000
605
wt.branch, log.LongLogFormatter)
607
731
def test_properties_in_short_log(self):
608
732
"""Log includes the custom properties returned by the registered
611
wt = self.make_standard_commit('test_properties_in_short_log')
612
def trivial_custom_prop_handler(revision):
613
return {'test_prop':'test_value'}
735
wt = self.make_branch_and_tree('.')
737
self.build_tree(['a'])
739
b.nick = 'test_properties_in_short_log'
740
wt.commit(message='add a',
741
timestamp=1132711707,
743
committer='Lorem Ipsum <test@example.com>',
744
authors=['John Doe <jdoe@example.com>'])
746
formatter = log.ShortLogFormatter(to_file=sio)
748
def trivial_custom_prop_handler(revision):
749
return {'test_prop':'test_value'}
615
log.properties_handler_registry.register(
616
'trivial_custom_prop_handler',
617
trivial_custom_prop_handler)
618
self.assertFormatterResult("""\
619
1 John Doe\t2005-11-22
751
log.properties_handler_registry.register(
752
'trivial_custom_prop_handler',
753
trivial_custom_prop_handler)
754
log.show_log(b, formatter)
756
log.properties_handler_registry.remove(
757
'trivial_custom_prop_handler')
758
self.assertEqualDiff('''\
759
1 John Doe\t2005-11-23
620
760
test_prop: test_value
624
wt.branch, log.ShortLogFormatter)
626
766
def test_error_in_properties_handler(self):
627
767
"""Log includes the custom properties returned by the registered
630
wt = self.make_standard_commit('error_in_properties_handler',
631
revprops={'first_prop':'first_value'})
632
sio = self.make_utf8_encoded_stringio()
770
wt = self.make_branch_and_tree('.')
772
self.build_tree(['a'])
774
b.nick = 'test_author_log'
775
wt.commit(message='add a',
776
timestamp=1132711707,
778
committer='Lorem Ipsum <test@example.com>',
779
authors=['John Doe <jdoe@example.com>'],
780
revprops={'first_prop':'first_value'})
633
782
formatter = log.LongLogFormatter(to_file=sio)
634
def trivial_custom_prop_handler(revision):
635
raise StandardError("a test error")
784
def trivial_custom_prop_handler(revision):
785
raise StandardError("a test error")
637
log.properties_handler_registry.register(
638
'trivial_custom_prop_handler',
639
trivial_custom_prop_handler)
640
self.assertRaises(StandardError, log.show_log, wt.branch, formatter,)
787
log.properties_handler_registry.register(
788
'trivial_custom_prop_handler',
789
trivial_custom_prop_handler)
790
self.assertRaises(StandardError, log.show_log, b, formatter,)
792
log.properties_handler_registry.remove(
793
'trivial_custom_prop_handler')
642
795
def test_properties_handler_bad_argument(self):
643
wt = self.make_standard_commit('bad_argument',
644
revprops={'a_prop':'test_value'})
645
sio = self.make_utf8_encoded_stringio()
796
wt = self.make_branch_and_tree('.')
798
self.build_tree(['a'])
800
b.nick = 'test_author_log'
801
wt.commit(message='add a',
802
timestamp=1132711707,
804
committer='Lorem Ipsum <test@example.com>',
805
authors=['John Doe <jdoe@example.com>'],
806
revprops={'a_prop':'test_value'})
646
808
formatter = log.LongLogFormatter(to_file=sio)
647
def bad_argument_prop_handler(revision):
648
return {'custom_prop_name':revision.properties['a_prop']}
650
log.properties_handler_registry.register(
651
'bad_argument_prop_handler',
652
bad_argument_prop_handler)
654
self.assertRaises(AttributeError, formatter.show_properties,
657
revision = wt.branch.repository.get_revision(wt.branch.last_revision())
658
formatter.show_properties(revision, '')
659
self.assertEqualDiff('''custom_prop_name: test_value\n''',
663
class TestLongLogFormatterWithoutMergeRevisions(TestCaseForLogFormatter):
810
def bad_argument_prop_handler(revision):
811
return {'custom_prop_name':revision.properties['a_prop']}
813
log.properties_handler_registry.register(
814
'bad_argument_prop_handler',
815
bad_argument_prop_handler)
817
self.assertRaises(AttributeError, formatter.show_properties,
820
revision = b.repository.get_revision(b.last_revision())
821
formatter.show_properties(revision, '')
822
self.assertEqualDiff('''custom_prop_name: test_value\n''',
825
log.properties_handler_registry.remove(
826
'bad_argument_prop_handler')
829
class TestLongLogFormatterWithoutMergeRevisions(TestCaseWithoutPropsHandler):
665
831
def test_long_verbose_log(self):
666
832
"""Verbose log includes changed files
670
wt = self.make_standard_commit('test_long_verbose_log', authors=[])
671
self.assertFormatterResult("""\
836
wt = self.make_branch_and_tree('.')
838
self.build_tree(['a'])
840
# XXX: why does a longer nick show up?
841
b.nick = 'test_verbose_log'
842
wt.commit(message='add a',
843
timestamp=1132711707,
845
committer='Lorem Ipsum <test@example.com>')
846
logfile = file('out.tmp', 'w+')
847
formatter = log.LongLogFormatter(to_file=logfile, levels=1)
848
log.show_log(b, formatter, verbose=True)
851
log_contents = logfile.read()
852
self.assertEqualDiff('''\
672
853
------------------------------------------------------------
674
855
committer: Lorem Ipsum <test@example.com>
675
branch nick: test_long_verbose_log
676
timestamp: Tue 2005-11-22 00:00:00 +0000
856
branch nick: test_verbose_log
857
timestamp: Wed 2005-11-23 12:08:27 +1000
682
wt.branch, log.LongLogFormatter,
683
formatter_kwargs=dict(levels=1),
684
show_log_kwargs=dict(verbose=True))
686
865
def test_long_verbose_contain_deltas(self):
687
866
wt = self.make_branch_and_tree('parent')
688
867
self.build_tree(['parent/f1', 'parent/f2'])
689
868
wt.add(['f1','f2'])
690
self.wt_commit(wt, 'first post')
691
child_wt = wt.bzrdir.sprout('child').open_workingtree()
869
wt.commit('first post')
870
self.run_bzr('branch parent child')
692
871
os.unlink('child/f1')
693
self.build_tree_contents([('child/f2', 'hello\n')])
694
self.wt_commit(child_wt, 'removed f1 and modified f2')
695
wt.merge_from_branch(child_wt.branch)
696
self.wt_commit(wt, 'merge branch 1')
697
self.assertFormatterResult("""\
872
file('child/f2', 'wb').write('hello\n')
873
self.run_bzr(['commit', '-m', 'removed f1 and modified f2',
876
self.run_bzr('merge ../child')
877
wt.commit('merge branch 1')
879
sio = self.make_utf8_encoded_stringio()
880
lf = log.LongLogFormatter(to_file=sio, levels=1)
881
log.show_log(b, lf, verbose=True)
882
the_log = normalize_log(sio.getvalue())
883
self.assertEqualDiff("""\
698
884
------------------------------------------------------------
700
committer: Joe Foo <joe@foo.com>
886
committer: Lorem Ipsum <test@example.com>
701
887
branch nick: parent
702
timestamp: Tue 2005-11-22 00:00:02 +0000
746
934
committer: Joe Foo <joe@foo.com>
747
935
branch nick: test
748
timestamp: Tue 2005-11-22 00:00:00 +0000
936
timestamp: Mon 2005-11-21 09:24:15 -0600
750
938
simple log message
752
b, log.LongLogFormatter,
753
formatter_kwargs=dict(levels=1))
755
942
def test_long_author_in_log(self):
756
943
"""Log includes the author name if it's set in
757
944
the revision properties
759
wt = self.make_standard_commit('test_author_log')
760
self.assertFormatterResult("""\
946
wt = self.make_branch_and_tree('.')
948
self.build_tree(['a'])
950
b.nick = 'test_author_log'
951
wt.commit(message='add a',
952
timestamp=1132711707,
954
committer='Lorem Ipsum <test@example.com>',
955
authors=['John Doe <jdoe@example.com>'])
957
formatter = log.LongLogFormatter(to_file=sio, levels=1)
958
log.show_log(b, formatter)
959
self.assertEqualDiff('''\
761
960
------------------------------------------------------------
763
962
author: John Doe <jdoe@example.com>
764
963
committer: Lorem Ipsum <test@example.com>
765
964
branch nick: test_author_log
766
timestamp: Tue 2005-11-22 00:00:00 +0000
965
timestamp: Wed 2005-11-23 12:08:27 +1000
770
wt.branch, log.LongLogFormatter,
771
formatter_kwargs=dict(levels=1))
773
971
def test_long_properties_in_log(self):
774
972
"""Log includes the custom properties returned by the registered
777
wt = self.make_standard_commit('test_properties_in_log')
778
def trivial_custom_prop_handler(revision):
779
return {'test_prop':'test_value'}
975
wt = self.make_branch_and_tree('.')
977
self.build_tree(['a'])
979
b.nick = 'test_properties_in_log'
980
wt.commit(message='add a',
981
timestamp=1132711707,
983
committer='Lorem Ipsum <test@example.com>',
984
authors=['John Doe <jdoe@example.com>'])
986
formatter = log.LongLogFormatter(to_file=sio, levels=1)
988
def trivial_custom_prop_handler(revision):
989
return {'test_prop':'test_value'}
781
log.properties_handler_registry.register(
782
'trivial_custom_prop_handler',
783
trivial_custom_prop_handler)
784
self.assertFormatterResult("""\
991
log.properties_handler_registry.register(
992
'trivial_custom_prop_handler',
993
trivial_custom_prop_handler)
994
log.show_log(b, formatter)
996
log.properties_handler_registry.remove(
997
'trivial_custom_prop_handler')
998
self.assertEqualDiff('''\
785
999
------------------------------------------------------------
787
1001
test_prop: test_value
788
1002
author: John Doe <jdoe@example.com>
789
1003
committer: Lorem Ipsum <test@example.com>
790
1004
branch nick: test_properties_in_log
791
timestamp: Tue 2005-11-22 00:00:00 +0000
1005
timestamp: Wed 2005-11-23 12:08:27 +1000
795
wt.branch, log.LongLogFormatter,
796
formatter_kwargs=dict(levels=1))
799
class TestLineLogFormatter(TestCaseForLogFormatter):
1012
class TestLineLogFormatter(tests.TestCaseWithTransport):
801
1014
def test_line_log(self):
802
1015
"""Line log should show revno
806
wt = self.make_standard_commit('test-line-log',
807
committer='Line-Log-Formatter Tester <test@line.log>',
809
self.assertFormatterResult("""\
810
1: Line-Log-Formatte... 2005-11-22 add a
812
wt.branch, log.LineLogFormatter)
1019
wt = self.make_branch_and_tree('.')
1021
self.build_tree(['a'])
1023
b.nick = 'test-line-log'
1024
wt.commit(message='add a',
1025
timestamp=1132711707,
1027
committer='Line-Log-Formatter Tester <test@line.log>')
1028
logfile = file('out.tmp', 'w+')
1029
formatter = log.LineLogFormatter(to_file=logfile)
1030
log.show_log(b, formatter)
1033
log_contents = logfile.read()
1034
self.assertEqualDiff('1: Line-Log-Formatte... 2005-11-23 add a\n',
814
1037
def test_trailing_newlines(self):
815
1038
wt = self.make_branch_and_tree('.')
816
b = self.make_commits_with_trailing_newlines(wt)
817
self.assertFormatterResult("""\
818
3: Joe Foo 2005-11-22 single line with trailing newline
819
2: Joe Foo 2005-11-22 multiline
820
1: Joe Foo 2005-11-22 simple log message
1039
b = make_commits_with_trailing_newlines(wt)
1040
sio = self.make_utf8_encoded_stringio()
1041
lf = log.LineLogFormatter(to_file=sio)
1043
self.assertEqualDiff("""\
1044
3: Joe Foo 2005-11-21 single line with trailing newline
1045
2: Joe Bar 2005-11-21 multiline
1046
1: Joe Foo 2005-11-21 simple log message
822
b, log.LineLogFormatter)
1050
def _prepare_tree_with_merges(self, with_tags=False):
1051
wt = self.make_branch_and_memory_tree('.')
1053
self.addCleanup(wt.unlock)
1055
wt.commit('rev-1', rev_id='rev-1',
1056
timestamp=1132586655, timezone=36000,
1057
committer='Joe Foo <joe@foo.com>')
1058
wt.commit('rev-merged', rev_id='rev-2a',
1059
timestamp=1132586700, timezone=36000,
1060
committer='Joe Foo <joe@foo.com>')
1061
wt.set_parent_ids(['rev-1', 'rev-2a'])
1062
wt.branch.set_last_revision_info(1, 'rev-1')
1063
wt.commit('rev-2', rev_id='rev-2b',
1064
timestamp=1132586800, timezone=36000,
1065
committer='Joe Foo <joe@foo.com>')
1068
branch.tags.set_tag('v0.2', 'rev-2b')
1069
wt.commit('rev-3', rev_id='rev-3',
1070
timestamp=1132586900, timezone=36000,
1071
committer='Jane Foo <jane@foo.com>')
1072
branch.tags.set_tag('v1.0rc1', 'rev-3')
1073
branch.tags.set_tag('v1.0', 'rev-3')
824
1076
def test_line_log_single_merge_revision(self):
825
1077
wt = self._prepare_tree_with_merges()
1078
logfile = self.make_utf8_encoded_stringio()
1079
formatter = log.LineLogFormatter(to_file=logfile)
826
1080
revspec = revisionspec.RevisionSpec.from_string('1.1.1')
827
rev = revspec.in_history(wt.branch)
828
self.assertFormatterResult("""\
1082
rev = revspec.in_history(wtb)
1083
log.show_log(wtb, formatter, start_revision=rev, end_revision=rev)
1084
self.assertEqualDiff("""\
829
1085
1.1.1: Joe Foo 2005-11-22 rev-merged
831
wt.branch, log.LineLogFormatter,
832
show_log_kwargs=dict(start_revision=rev, end_revision=rev))
834
1089
def test_line_log_with_tags(self):
835
1090
wt = self._prepare_tree_with_merges(with_tags=True)
836
self.assertFormatterResult("""\
837
3: Joe Foo 2005-11-22 {v1.0, v1.0rc1} rev-3
1091
logfile = self.make_utf8_encoded_stringio()
1092
formatter = log.LineLogFormatter(to_file=logfile)
1093
log.show_log(wt.branch, formatter)
1094
self.assertEqualDiff("""\
1095
3: Jane Foo 2005-11-22 {v1.0, v1.0rc1} rev-3
838
1096
2: Joe Foo 2005-11-22 [merge] {v0.2} rev-2
839
1097
1: Joe Foo 2005-11-22 rev-1
841
wt.branch, log.LineLogFormatter)
844
class TestLineLogFormatterWithMergeRevisions(TestCaseForLogFormatter):
1101
class TestLineLogFormatterWithMergeRevisions(tests.TestCaseWithTransport):
846
1103
def test_line_merge_revs_log(self):
847
1104
"""Line log should show revno
851
wt = self.make_standard_commit('test-line-log',
852
committer='Line-Log-Formatter Tester <test@line.log>',
854
self.assertFormatterResult("""\
855
1: Line-Log-Formatte... 2005-11-22 add a
857
wt.branch, log.LineLogFormatter)
1108
wt = self.make_branch_and_tree('.')
1110
self.build_tree(['a'])
1112
b.nick = 'test-line-log'
1113
wt.commit(message='add a',
1114
timestamp=1132711707,
1116
committer='Line-Log-Formatter Tester <test@line.log>')
1117
logfile = file('out.tmp', 'w+')
1118
formatter = log.LineLogFormatter(to_file=logfile, levels=0)
1119
log.show_log(b, formatter)
1122
log_contents = logfile.read()
1123
self.assertEqualDiff('1: Line-Log-Formatte... 2005-11-23 add a\n',
859
1126
def test_line_merge_revs_log_single_merge_revision(self):
860
wt = self._prepare_tree_with_merges()
1127
wt = self.make_branch_and_memory_tree('.')
1129
self.addCleanup(wt.unlock)
1131
wt.commit('rev-1', rev_id='rev-1',
1132
timestamp=1132586655, timezone=36000,
1133
committer='Joe Foo <joe@foo.com>')
1134
wt.commit('rev-merged', rev_id='rev-2a',
1135
timestamp=1132586700, timezone=36000,
1136
committer='Joe Foo <joe@foo.com>')
1137
wt.set_parent_ids(['rev-1', 'rev-2a'])
1138
wt.branch.set_last_revision_info(1, 'rev-1')
1139
wt.commit('rev-2', rev_id='rev-2b',
1140
timestamp=1132586800, timezone=36000,
1141
committer='Joe Foo <joe@foo.com>')
1142
logfile = self.make_utf8_encoded_stringio()
1143
formatter = log.LineLogFormatter(to_file=logfile, levels=0)
861
1144
revspec = revisionspec.RevisionSpec.from_string('1.1.1')
862
rev = revspec.in_history(wt.branch)
863
self.assertFormatterResult("""\
1146
rev = revspec.in_history(wtb)
1147
log.show_log(wtb, formatter, start_revision=rev, end_revision=rev)
1148
self.assertEqualDiff("""\
864
1149
1.1.1: Joe Foo 2005-11-22 rev-merged
866
wt.branch, log.LineLogFormatter,
867
formatter_kwargs=dict(levels=0),
868
show_log_kwargs=dict(start_revision=rev, end_revision=rev))
870
1153
def test_line_merge_revs_log_with_merges(self):
871
wt = self._prepare_tree_with_merges()
872
self.assertFormatterResult("""\
1154
wt = self.make_branch_and_memory_tree('.')
1156
self.addCleanup(wt.unlock)
1158
wt.commit('rev-1', rev_id='rev-1',
1159
timestamp=1132586655, timezone=36000,
1160
committer='Joe Foo <joe@foo.com>')
1161
wt.commit('rev-merged', rev_id='rev-2a',
1162
timestamp=1132586700, timezone=36000,
1163
committer='Joe Foo <joe@foo.com>')
1164
wt.set_parent_ids(['rev-1', 'rev-2a'])
1165
wt.branch.set_last_revision_info(1, 'rev-1')
1166
wt.commit('rev-2', rev_id='rev-2b',
1167
timestamp=1132586800, timezone=36000,
1168
committer='Joe Foo <joe@foo.com>')
1169
logfile = self.make_utf8_encoded_stringio()
1170
formatter = log.LineLogFormatter(to_file=logfile, levels=0)
1171
log.show_log(wt.branch, formatter)
1172
self.assertEqualDiff("""\
873
1173
2: Joe Foo 2005-11-22 [merge] rev-2
874
1174
1.1.1: Joe Foo 2005-11-22 rev-merged
875
1175
1: Joe Foo 2005-11-22 rev-1
877
wt.branch, log.LineLogFormatter,
878
formatter_kwargs=dict(levels=0))
881
class TestGnuChangelogFormatter(TestCaseForLogFormatter):
883
def test_gnu_changelog(self):
884
wt = self.make_standard_commit('nicky', authors=[])
885
self.assertFormatterResult('''\
886
2005-11-22 Lorem Ipsum <test@example.com>
891
wt.branch, log.GnuChangelogLogFormatter)
893
def test_with_authors(self):
894
wt = self.make_standard_commit('nicky',
895
authors=['Fooa Fooz <foo@example.com>',
896
'Bari Baro <bar@example.com>'])
897
self.assertFormatterResult('''\
898
2005-11-22 Fooa Fooz <foo@example.com>
903
wt.branch, log.GnuChangelogLogFormatter)
905
def test_verbose(self):
906
wt = self.make_standard_commit('nicky')
907
self.assertFormatterResult('''\
908
2005-11-22 John Doe <jdoe@example.com>
915
wt.branch, log.GnuChangelogLogFormatter,
916
show_log_kwargs=dict(verbose=True))
918
class TestGetViewRevisions(tests.TestCaseWithTransport, TestLogMixin):
920
def _get_view_revisions(self, *args, **kwargs):
921
return self.applyDeprecated(symbol_versioning.deprecated_in((2, 2, 0)),
922
log.get_view_revisions, *args, **kwargs)
1179
class TestGetViewRevisions(tests.TestCaseWithTransport):
924
1181
def make_tree_with_commits(self):
925
1182
"""Create a tree with well-known revision ids"""
926
1183
wt = self.make_branch_and_tree('tree1')
927
self.wt_commit(wt, 'commit one', rev_id='1')
928
self.wt_commit(wt, 'commit two', rev_id='2')
929
self.wt_commit(wt, 'commit three', rev_id='3')
1184
wt.commit('commit one', rev_id='1')
1185
wt.commit('commit two', rev_id='2')
1186
wt.commit('commit three', rev_id='3')
930
1187
mainline_revs = [None, '1', '2', '3']
931
1188
rev_nos = {'1': 1, '2': 2, '3': 3}
932
1189
return mainline_revs, rev_nos, wt
1275
1522
class TestLogFormatter(tests.TestCase):
1278
super(TestLogFormatter, self).setUp()
1279
self.rev = revision.Revision('a-id')
1280
self.lf = log.LogFormatter(None)
1282
1524
def test_short_committer(self):
1283
def assertCommitter(expected, committer):
1284
self.rev.committer = committer
1285
self.assertEqual(expected, self.lf.short_committer(self.rev))
1287
assertCommitter('John Doe', 'John Doe <jdoe@example.com>')
1288
assertCommitter('John Smith', 'John Smith <jsmith@example.com>')
1289
assertCommitter('John Smith', 'John Smith')
1290
assertCommitter('jsmith@example.com', 'jsmith@example.com')
1291
assertCommitter('jsmith@example.com', '<jsmith@example.com>')
1292
assertCommitter('John Smith', 'John Smith jsmith@example.com')
1525
rev = revision.Revision('a-id')
1526
rev.committer = 'John Doe <jdoe@example.com>'
1527
lf = log.LogFormatter(None)
1528
self.assertEqual('John Doe', lf.short_committer(rev))
1529
rev.committer = 'John Smith <jsmith@example.com>'
1530
self.assertEqual('John Smith', lf.short_committer(rev))
1531
rev.committer = 'John Smith'
1532
self.assertEqual('John Smith', lf.short_committer(rev))
1533
rev.committer = 'jsmith@example.com'
1534
self.assertEqual('jsmith@example.com', lf.short_committer(rev))
1535
rev.committer = '<jsmith@example.com>'
1536
self.assertEqual('jsmith@example.com', lf.short_committer(rev))
1537
rev.committer = 'John Smith jsmith@example.com'
1538
self.assertEqual('John Smith', lf.short_committer(rev))
1294
1540
def test_short_author(self):
1295
def assertAuthor(expected, author):
1296
self.rev.properties['author'] = author
1297
self.assertEqual(expected, self.lf.short_author(self.rev))
1299
assertAuthor('John Smith', 'John Smith <jsmith@example.com>')
1300
assertAuthor('John Smith', 'John Smith')
1301
assertAuthor('jsmith@example.com', 'jsmith@example.com')
1302
assertAuthor('jsmith@example.com', '<jsmith@example.com>')
1303
assertAuthor('John Smith', 'John Smith jsmith@example.com')
1305
def test_short_author_from_committer(self):
1306
self.rev.committer = 'John Doe <jdoe@example.com>'
1307
self.assertEqual('John Doe', self.lf.short_author(self.rev))
1309
def test_short_author_from_authors(self):
1310
self.rev.properties['authors'] = ('John Smith <jsmith@example.com>\n'
1311
'Jane Rey <jrey@example.com>')
1312
self.assertEqual('John Smith', self.lf.short_author(self.rev))
1541
rev = revision.Revision('a-id')
1542
rev.committer = 'John Doe <jdoe@example.com>'
1543
lf = log.LogFormatter(None)
1544
self.assertEqual('John Doe', lf.short_author(rev))
1545
rev.properties['author'] = 'John Smith <jsmith@example.com>'
1546
self.assertEqual('John Smith', lf.short_author(rev))
1547
rev.properties['author'] = 'John Smith'
1548
self.assertEqual('John Smith', lf.short_author(rev))
1549
rev.properties['author'] = 'jsmith@example.com'
1550
self.assertEqual('jsmith@example.com', lf.short_author(rev))
1551
rev.properties['author'] = '<jsmith@example.com>'
1552
self.assertEqual('jsmith@example.com', lf.short_author(rev))
1553
rev.properties['author'] = 'John Smith jsmith@example.com'
1554
self.assertEqual('John Smith', lf.short_author(rev))
1555
del rev.properties['author']
1556
rev.properties['authors'] = ('John Smith <jsmith@example.com>\n'
1557
'Jane Rey <jrey@example.com>')
1558
self.assertEqual('John Smith', lf.short_author(rev))
1315
1561
class TestReverseByDepth(tests.TestCase):
1461
1707
log.show_branch_change(tree.branch, s, 3, '3b')
1462
1708
self.assertContainsRe(s.getvalue(), 'Removed Revisions:')
1463
1709
self.assertNotContainsRe(s.getvalue(), 'Added Revisions:')
1467
class TestLogWithBugs(TestCaseForLogFormatter, TestLogMixin):
1470
TestCaseForLogFormatter.setUp(self)
1471
log.properties_handler_registry.register(
1472
'bugs_properties_handler',
1473
log._bugs_properties_handler)
1475
def make_commits_with_bugs(self):
1476
"""Helper method for LogFormatter tests"""
1477
tree = self.make_branch_and_tree(u'.')
1478
self.build_tree(['a', 'b'])
1480
self.wt_commit(tree, 'simple log message', rev_id='a1',
1481
revprops={'bugs': 'test://bug/id fixed'})
1483
self.wt_commit(tree, 'multiline\nlog\nmessage\n', rev_id='a2',
1484
authors=['Joe Bar <joe@bar.com>'],
1485
revprops={'bugs': 'test://bug/id fixed\n'
1486
'test://bug/2 fixed'})
1490
def test_long_bugs(self):
1491
tree = self.make_commits_with_bugs()
1492
self.assertFormatterResult("""\
1493
------------------------------------------------------------
1495
fixes bug(s): test://bug/id test://bug/2
1496
author: Joe Bar <joe@bar.com>
1497
committer: Joe Foo <joe@foo.com>
1499
timestamp: Tue 2005-11-22 00:00:01 +0000
1504
------------------------------------------------------------
1506
fixes bug(s): test://bug/id
1507
committer: Joe Foo <joe@foo.com>
1509
timestamp: Tue 2005-11-22 00:00:00 +0000
1513
tree.branch, log.LongLogFormatter)
1515
def test_short_bugs(self):
1516
tree = self.make_commits_with_bugs()
1517
self.assertFormatterResult("""\
1518
2 Joe Bar\t2005-11-22
1519
fixes bug(s): test://bug/id test://bug/2
1524
1 Joe Foo\t2005-11-22
1525
fixes bug(s): test://bug/id
1529
tree.branch, log.ShortLogFormatter)
1531
def test_wrong_bugs_property(self):
1532
tree = self.make_branch_and_tree(u'.')
1533
self.build_tree(['foo'])
1534
self.wt_commit(tree, 'simple log message', rev_id='a1',
1535
revprops={'bugs': 'test://bug/id invalid_value'})
1536
self.assertFormatterResult("""\
1537
1 Joe Foo\t2005-11-22
1541
tree.branch, log.ShortLogFormatter)
1543
def test_bugs_handler_present(self):
1544
self.properties_handler_registry.get('bugs_properties_handler')
1546
class TestLogExcludeAncestry(tests.TestCaseWithTransport):
1548
def make_branch_with_alternate_ancestries(self, relpath='.'):
1549
# See test_merge_sorted_exclude_ancestry below for the difference with
1550
# bt.per_branch.test_iter_merge_sorted_revision.
1551
# TestIterMergeSortedRevisionsBushyGraph.
1552
# make_branch_with_alternate_ancestries
1553
# and test_merge_sorted_exclude_ancestry
1554
# See the FIXME in assertLogRevnos too.
1555
builder = branchbuilder.BranchBuilder(self.get_transport(relpath))
1567
builder.start_series()
1568
builder.build_snapshot('1', None, [
1569
('add', ('', 'TREE_ROOT', 'directory', '')),])
1570
builder.build_snapshot('1.1.1', ['1'], [])
1571
builder.build_snapshot('2', ['1'], [])
1572
builder.build_snapshot('1.2.1', ['1.1.1'], [])
1573
builder.build_snapshot('1.1.2', ['1.1.1', '1.2.1'], [])
1574
builder.build_snapshot('3', ['2', '1.1.2'], [])
1575
builder.finish_series()
1576
br = builder.get_branch()
1578
self.addCleanup(br.unlock)
1581
def assertLogRevnos(self, expected_revnos, b, start, end,
1582
exclude_common_ancestry):
1583
# FIXME: the layering in log makes it hard to test intermediate levels,
1584
# I wish adding filters with their parameters were easier...
1586
iter_revs = log._calc_view_revisions(
1587
b, start, end, direction='reverse',
1588
generate_merge_revisions=True,
1589
exclude_common_ancestry=exclude_common_ancestry)
1590
self.assertEqual(expected_revnos,
1591
[revid for revid, revno, depth in iter_revs])
1593
def test_merge_sorted_exclude_ancestry(self):
1594
b = self.make_branch_with_alternate_ancestries()
1595
self.assertLogRevnos(['3', '1.1.2', '1.2.1', '1.1.1', '2', '1'],
1597
# '2' is part of the '3' ancestry but not part of '1.1.1' ancestry so
1598
# it should be mentioned even if merge_sort order will make it appear
1600
self.assertLogRevnos(['3', '1.1.2', '1.2.1', '2'],
1601
b, '1.1.1', '3', True)