410
410
rev = revspec.in_history(wtb)
411
411
log.show_log(wtb, formatter, start_revision=rev, end_revision=rev)
412
412
self.assertEqualDiff("""\
413
1.1.1 Joe Foo\t2005-11-22
413
1.1.1 Joe Foo\t2005-11-22
420
class TestShortLogFormatterWithMergeRevisions(tests.TestCaseWithTransport):
422
def test_short_merge_revs_log_with_merges(self):
423
wt = self.make_branch_and_memory_tree('.')
425
self.addCleanup(wt.unlock)
427
wt.commit('rev-1', rev_id='rev-1',
428
timestamp=1132586655, timezone=36000,
429
committer='Joe Foo <joe@foo.com>')
430
wt.commit('rev-merged', rev_id='rev-2a',
431
timestamp=1132586700, timezone=36000,
432
committer='Joe Foo <joe@foo.com>')
433
wt.set_parent_ids(['rev-1', 'rev-2a'])
434
wt.branch.set_last_revision_info(1, 'rev-1')
435
wt.commit('rev-2', rev_id='rev-2b',
436
timestamp=1132586800, timezone=36000,
437
committer='Joe Foo <joe@foo.com>')
438
logfile = self.make_utf8_encoded_stringio()
439
formatter = log.ShortLogFormatter(to_file=logfile, levels=0)
440
log.show_log(wt.branch, formatter)
441
# Note that the 1.1.1 indenting is in fact correct given that
442
# the revision numbers are right justified within 5 characters
443
# for mainline revnos and 9 characters for dotted revnos.
444
self.assertEqualDiff("""\
445
2 Joe Foo\t2005-11-22 [merge]
448
1.1.1 Joe Foo\t2005-11-22
451
1 Joe Foo\t2005-11-22
457
def test_short_merge_revs_log_single_merge_revision(self):
458
wt = self.make_branch_and_memory_tree('.')
460
self.addCleanup(wt.unlock)
462
wt.commit('rev-1', rev_id='rev-1',
463
timestamp=1132586655, timezone=36000,
464
committer='Joe Foo <joe@foo.com>')
465
wt.commit('rev-merged', rev_id='rev-2a',
466
timestamp=1132586700, timezone=36000,
467
committer='Joe Foo <joe@foo.com>')
468
wt.set_parent_ids(['rev-1', 'rev-2a'])
469
wt.branch.set_last_revision_info(1, 'rev-1')
470
wt.commit('rev-2', rev_id='rev-2b',
471
timestamp=1132586800, timezone=36000,
472
committer='Joe Foo <joe@foo.com>')
473
logfile = self.make_utf8_encoded_stringio()
474
formatter = log.ShortLogFormatter(to_file=logfile, levels=0)
475
revspec = revisionspec.RevisionSpec.from_string('1.1.1')
477
rev = revspec.in_history(wtb)
478
log.show_log(wtb, formatter, start_revision=rev, end_revision=rev)
479
self.assertEqualDiff("""\
480
1.1.1 Joe Foo\t2005-11-22
417
484
logfile.getvalue())
731
798
'bad_argument_prop_handler')
801
class TestLongLogFormatterWithoutMergeRevisions(TestCaseWithoutPropsHandler):
803
def test_long_verbose_log(self):
804
"""Verbose log includes changed files
808
wt = self.make_branch_and_tree('.')
810
self.build_tree(['a'])
812
# XXX: why does a longer nick show up?
813
b.nick = 'test_verbose_log'
814
wt.commit(message='add a',
815
timestamp=1132711707,
817
committer='Lorem Ipsum <test@example.com>')
818
logfile = file('out.tmp', 'w+')
819
formatter = log.LongLogFormatter(to_file=logfile, levels=1)
820
log.show_log(b, formatter, verbose=True)
823
log_contents = logfile.read()
824
self.assertEqualDiff('''\
825
------------------------------------------------------------
827
committer: Lorem Ipsum <test@example.com>
828
branch nick: test_verbose_log
829
timestamp: Wed 2005-11-23 12:08:27 +1000
837
def test_long_verbose_contain_deltas(self):
838
wt = self.make_branch_and_tree('parent')
839
self.build_tree(['parent/f1', 'parent/f2'])
841
wt.commit('first post')
842
self.run_bzr('branch parent child')
843
os.unlink('child/f1')
844
file('child/f2', 'wb').write('hello\n')
845
self.run_bzr(['commit', '-m', 'removed f1 and modified f2',
848
self.run_bzr('merge ../child')
849
wt.commit('merge branch 1')
851
sio = self.make_utf8_encoded_stringio()
852
lf = log.LongLogFormatter(to_file=sio, levels=1)
853
log.show_log(b, lf, verbose=True)
854
the_log = normalize_log(sio.getvalue())
855
self.assertEqualDiff("""\
856
------------------------------------------------------------
858
committer: Lorem Ipsum <test@example.com>
867
------------------------------------------------------------
869
committer: Lorem Ipsum <test@example.com>
880
def test_long_trailing_newlines(self):
881
wt = self.make_branch_and_tree('.')
882
b = make_commits_with_trailing_newlines(wt)
883
sio = self.make_utf8_encoded_stringio()
884
lf = log.LongLogFormatter(to_file=sio, levels=1)
886
self.assertEqualDiff("""\
887
------------------------------------------------------------
889
committer: Joe Foo <joe@foo.com>
891
timestamp: Mon 2005-11-21 09:32:56 -0600
893
single line with trailing newline
894
------------------------------------------------------------
896
author: Joe Bar <joe@bar.com>
897
committer: Joe Foo <joe@foo.com>
899
timestamp: Mon 2005-11-21 09:27:22 -0600
904
------------------------------------------------------------
906
committer: Joe Foo <joe@foo.com>
908
timestamp: Mon 2005-11-21 09:24:15 -0600
914
def test_long_author_in_log(self):
915
"""Log includes the author name if it's set in
916
the revision properties
918
wt = self.make_branch_and_tree('.')
920
self.build_tree(['a'])
922
b.nick = 'test_author_log'
923
wt.commit(message='add a',
924
timestamp=1132711707,
926
committer='Lorem Ipsum <test@example.com>',
927
author='John Doe <jdoe@example.com>')
929
formatter = log.LongLogFormatter(to_file=sio, levels=1)
930
log.show_log(b, formatter)
931
self.assertEqualDiff('''\
932
------------------------------------------------------------
934
author: John Doe <jdoe@example.com>
935
committer: Lorem Ipsum <test@example.com>
936
branch nick: test_author_log
937
timestamp: Wed 2005-11-23 12:08:27 +1000
943
def test_long_properties_in_log(self):
944
"""Log includes the custom properties returned by the registered
947
wt = self.make_branch_and_tree('.')
949
self.build_tree(['a'])
951
b.nick = 'test_properties_in_log'
952
wt.commit(message='add a',
953
timestamp=1132711707,
955
committer='Lorem Ipsum <test@example.com>',
956
author='John Doe <jdoe@example.com>')
958
formatter = log.LongLogFormatter(to_file=sio, levels=1)
960
def trivial_custom_prop_handler(revision):
961
return {'test_prop':'test_value'}
963
log.properties_handler_registry.register(
964
'trivial_custom_prop_handler',
965
trivial_custom_prop_handler)
966
log.show_log(b, formatter)
968
log.properties_handler_registry.remove(
969
'trivial_custom_prop_handler')
970
self.assertEqualDiff('''\
971
------------------------------------------------------------
973
test_prop: test_value
974
author: John Doe <jdoe@example.com>
975
committer: Lorem Ipsum <test@example.com>
976
branch nick: test_properties_in_log
977
timestamp: Wed 2005-11-23 12:08:27 +1000
734
984
class TestLineLogFormatter(tests.TestCaseWithTransport):
736
986
def test_line_log(self):
821
1071
logfile.getvalue())
1073
class TestLineLogFormatterWithMergeRevisions(tests.TestCaseWithTransport):
1075
def test_line_merge_revs_log(self):
1076
"""Line log should show revno
1080
wt = self.make_branch_and_tree('.')
1082
self.build_tree(['a'])
1084
b.nick = 'test-line-log'
1085
wt.commit(message='add a',
1086
timestamp=1132711707,
1088
committer='Line-Log-Formatter Tester <test@line.log>')
1089
logfile = file('out.tmp', 'w+')
1090
formatter = log.LineLogFormatter(to_file=logfile, levels=0)
1091
log.show_log(b, formatter)
1094
log_contents = logfile.read()
1095
self.assertEqualDiff('1: Line-Log-Formatte... 2005-11-23 add a\n',
1098
def test_line_merge_revs_log_single_merge_revision(self):
1099
wt = self.make_branch_and_memory_tree('.')
1101
self.addCleanup(wt.unlock)
1103
wt.commit('rev-1', rev_id='rev-1',
1104
timestamp=1132586655, timezone=36000,
1105
committer='Joe Foo <joe@foo.com>')
1106
wt.commit('rev-merged', rev_id='rev-2a',
1107
timestamp=1132586700, timezone=36000,
1108
committer='Joe Foo <joe@foo.com>')
1109
wt.set_parent_ids(['rev-1', 'rev-2a'])
1110
wt.branch.set_last_revision_info(1, 'rev-1')
1111
wt.commit('rev-2', rev_id='rev-2b',
1112
timestamp=1132586800, timezone=36000,
1113
committer='Joe Foo <joe@foo.com>')
1114
logfile = self.make_utf8_encoded_stringio()
1115
formatter = log.LineLogFormatter(to_file=logfile, levels=0)
1116
revspec = revisionspec.RevisionSpec.from_string('1.1.1')
1118
rev = revspec.in_history(wtb)
1119
log.show_log(wtb, formatter, start_revision=rev, end_revision=rev)
1120
self.assertEqualDiff("""\
1121
1.1.1: Joe Foo 2005-11-22 rev-merged
1125
def test_line_merge_revs_log_with_merges(self):
1126
wt = self.make_branch_and_memory_tree('.')
1128
self.addCleanup(wt.unlock)
1130
wt.commit('rev-1', rev_id='rev-1',
1131
timestamp=1132586655, timezone=36000,
1132
committer='Joe Foo <joe@foo.com>')
1133
wt.commit('rev-merged', rev_id='rev-2a',
1134
timestamp=1132586700, timezone=36000,
1135
committer='Joe Foo <joe@foo.com>')
1136
wt.set_parent_ids(['rev-1', 'rev-2a'])
1137
wt.branch.set_last_revision_info(1, 'rev-1')
1138
wt.commit('rev-2', rev_id='rev-2b',
1139
timestamp=1132586800, timezone=36000,
1140
committer='Joe Foo <joe@foo.com>')
1141
logfile = self.make_utf8_encoded_stringio()
1142
formatter = log.LineLogFormatter(to_file=logfile, levels=0)
1143
log.show_log(wt.branch, formatter)
1144
self.assertEqualDiff("""\
1145
2: Joe Foo 2005-11-22 rev-2
1146
1.1.1: Joe Foo 2005-11-22 rev-merged
1147
1: Joe Foo 2005-11-22 rev-1
824
1151
class TestGetViewRevisions(tests.TestCaseWithTransport):