194
201
d = logentry.delta
195
202
self.checkDelta(d, added=['file1', 'file2'])
204
def test_merges_nonsupporting_formatter(self):
205
"""Tests that show_log will raise if the formatter doesn't
206
support merge revisions."""
207
wt = self.make_branch_and_memory_tree('.')
211
wt.commit('rev-1', rev_id='rev-1',
212
timestamp=1132586655, timezone=36000,
213
committer='Joe Foo <joe@foo.com>')
214
wt.commit('rev-merged', rev_id='rev-2a',
215
timestamp=1132586700, timezone=36000,
216
committer='Joe Foo <joe@foo.com>')
217
wt.set_parent_ids(['rev-1', 'rev-2a'])
218
wt.branch.set_last_revision_info(1, 'rev-1')
219
wt.commit('rev-2', rev_id='rev-2b',
220
timestamp=1132586800, timezone=36000,
221
committer='Joe Foo <joe@foo.com>')
222
logfile = self.make_utf8_encoded_stringio()
223
formatter = ShortLogFormatter(to_file=logfile)
226
revspec = RevisionSpec.from_string('1.1.1')
227
rev = revspec.in_history(wtb)
228
self.assertRaises(BzrCommandError, show_log, wtb, lf,
229
start_revision=rev, end_revision=rev)
198
234
def make_commits_with_trailing_newlines(wt):
199
235
"""Helper method for LogFormatter tests"""
258
def normalize_log(log):
259
"""Replaces the variable lines of logs with fixed lines"""
260
author = 'author: Dolor Sit <test@example.com>'
261
committer = 'committer: Lorem Ipsum <test@example.com>'
262
lines = log.splitlines(True)
263
for idx,line in enumerate(lines):
264
stripped_line = line.lstrip()
265
indent = ' ' * (len(line) - len(stripped_line))
266
if stripped_line.startswith('author:'):
267
lines[idx] = indent + author + '\n'
268
elif stripped_line.startswith('committer:'):
269
lines[idx] = indent + committer + '\n'
270
elif stripped_line.startswith('timestamp:'):
271
lines[idx] = indent + 'timestamp: Just now\n'
272
return ''.join(lines)
222
275
class TestShortLogFormatter(TestCaseWithTransport):
224
277
def test_trailing_newlines(self):
297
def test_short_log_with_merges(self):
298
wt = self.make_branch_and_memory_tree('.')
302
wt.commit('rev-1', rev_id='rev-1',
303
timestamp=1132586655, timezone=36000,
304
committer='Joe Foo <joe@foo.com>')
305
wt.commit('rev-merged', rev_id='rev-2a',
306
timestamp=1132586700, timezone=36000,
307
committer='Joe Foo <joe@foo.com>')
308
wt.set_parent_ids(['rev-1', 'rev-2a'])
309
wt.branch.set_last_revision_info(1, 'rev-1')
310
wt.commit('rev-2', rev_id='rev-2b',
311
timestamp=1132586800, timezone=36000,
312
committer='Joe Foo <joe@foo.com>')
313
logfile = self.make_utf8_encoded_stringio()
314
formatter = ShortLogFormatter(to_file=logfile)
315
show_log(wt.branch, formatter)
316
self.assertEqualDiff(logfile.getvalue(), """\
317
2 Joe Foo\t2005-11-22 [merge]
320
1 Joe Foo\t2005-11-22
327
def test_short_log_single_merge_revision(self):
328
wt = self.make_branch_and_memory_tree('.')
332
wt.commit('rev-1', rev_id='rev-1',
333
timestamp=1132586655, timezone=36000,
334
committer='Joe Foo <joe@foo.com>')
335
wt.commit('rev-merged', rev_id='rev-2a',
336
timestamp=1132586700, timezone=36000,
337
committer='Joe Foo <joe@foo.com>')
338
wt.set_parent_ids(['rev-1', 'rev-2a'])
339
wt.branch.set_last_revision_info(1, 'rev-1')
340
wt.commit('rev-2', rev_id='rev-2b',
341
timestamp=1132586800, timezone=36000,
342
committer='Joe Foo <joe@foo.com>')
343
logfile = self.make_utf8_encoded_stringio()
344
formatter = ShortLogFormatter(to_file=logfile)
345
revspec = RevisionSpec.from_string('1.1.1')
347
rev = revspec.in_history(wtb)
348
show_log(wtb, formatter, start_revision=rev, end_revision=rev)
349
self.assertEqualDiff(logfile.getvalue(), """\
350
1.1.1 Joe Foo\t2005-11-22
245
358
class TestLongLogFormatter(TestCaseWithTransport):
247
def normalize_log(self,log):
248
"""Replaces the variable lines of logs with fixed lines"""
249
author = 'author: Dolor Sit <test@example.com>'
250
committer = 'committer: Lorem Ipsum <test@example.com>'
251
lines = log.splitlines(True)
252
for idx,line in enumerate(lines):
253
stripped_line = line.lstrip()
254
indent = ' ' * (len(line) - len(stripped_line))
255
if stripped_line.startswith('author:'):
256
lines[idx] = indent + author + '\n'
257
elif stripped_line.startswith('committer:'):
258
lines[idx] = indent + committer + '\n'
259
elif stripped_line.startswith('timestamp:'):
260
lines[idx] = indent + 'timestamp: Just now\n'
261
return ''.join(lines)
263
360
def test_verbose_log(self):
264
361
"""Verbose log includes changed files
490
587
log_contents = logfile.read()
491
self.assertEqualDiff(log_contents, '1: Line-Log-Formatte... 2005-11-23 add a\n')
493
def test_short_log_with_merges(self):
494
wt = self.make_branch_and_memory_tree('.')
498
wt.commit('rev-1', rev_id='rev-1',
499
timestamp=1132586655, timezone=36000,
500
committer='Joe Foo <joe@foo.com>')
501
wt.commit('rev-merged', rev_id='rev-2a',
502
timestamp=1132586700, timezone=36000,
503
committer='Joe Foo <joe@foo.com>')
504
wt.set_parent_ids(['rev-1', 'rev-2a'])
505
wt.branch.set_last_revision_info(1, 'rev-1')
506
wt.commit('rev-2', rev_id='rev-2b',
507
timestamp=1132586800, timezone=36000,
508
committer='Joe Foo <joe@foo.com>')
509
logfile = self.make_utf8_encoded_stringio()
510
formatter = ShortLogFormatter(to_file=logfile)
511
show_log(wt.branch, formatter)
513
self.assertEqualDiff("""\
514
2 Joe Foo\t2005-11-22 [merge]
517
1 Joe Foo\t2005-11-22
520
""", logfile.getvalue())
588
self.assertEqualDiff(log_contents,
589
'1: Line-Log-Formatte... 2005-11-23 add a\n')
524
591
def test_trailing_newlines(self):
525
592
wt = self.make_branch_and_tree('.')
533
600
1: Joe Foo 2005-11-21 simple log message
603
def test_line_log_single_merge_revision(self):
604
wt = self.make_branch_and_memory_tree('.')
608
wt.commit('rev-1', rev_id='rev-1',
609
timestamp=1132586655, timezone=36000,
610
committer='Joe Foo <joe@foo.com>')
611
wt.commit('rev-merged', rev_id='rev-2a',
612
timestamp=1132586700, timezone=36000,
613
committer='Joe Foo <joe@foo.com>')
614
wt.set_parent_ids(['rev-1', 'rev-2a'])
615
wt.branch.set_last_revision_info(1, 'rev-1')
616
wt.commit('rev-2', rev_id='rev-2b',
617
timestamp=1132586800, timezone=36000,
618
committer='Joe Foo <joe@foo.com>')
619
logfile = self.make_utf8_encoded_stringio()
620
formatter = LineLogFormatter(to_file=logfile)
621
revspec = RevisionSpec.from_string('1.1.1')
623
rev = revspec.in_history(wtb)
624
show_log(wtb, formatter, start_revision=rev, end_revision=rev)
625
self.assertEqualDiff(logfile.getvalue(), """\
626
1.1.1: Joe Foo 2005-11-22 rev-merged
537
633
class TestGetViewRevisions(TestCaseWithTransport):
806
902
rev.committer = 'John Doe <jdoe@example.com>'
807
903
lf = LogFormatter(None)
808
904
self.assertEqual('John Doe', lf.short_committer(rev))
905
rev.committer = 'John Smith <jsmith@example.com>'
906
self.assertEqual('John Smith', lf.short_committer(rev))
907
rev.committer = 'John Smith'
908
self.assertEqual('John Smith', lf.short_committer(rev))
909
rev.committer = 'jsmith@example.com'
910
self.assertEqual('jsmith@example.com', lf.short_committer(rev))
911
rev.committer = '<jsmith@example.com>'
912
self.assertEqual('jsmith@example.com', lf.short_committer(rev))
913
rev.committer = 'John Smith jsmith@example.com'
914
self.assertEqual('John Smith', lf.short_committer(rev))
810
916
def test_short_author(self):
811
917
rev = Revision('a-id')
814
920
self.assertEqual('John Doe', lf.short_author(rev))
815
921
rev.properties['author'] = 'John Smith <jsmith@example.com>'
816
922
self.assertEqual('John Smith', lf.short_author(rev))
923
rev.properties['author'] = 'John Smith'
924
self.assertEqual('John Smith', lf.short_author(rev))
925
rev.properties['author'] = 'jsmith@example.com'
926
self.assertEqual('jsmith@example.com', lf.short_author(rev))
927
rev.properties['author'] = '<jsmith@example.com>'
928
self.assertEqual('jsmith@example.com', lf.short_author(rev))
929
rev.properties['author'] = 'John Smith jsmith@example.com'
930
self.assertEqual('John Smith', lf.short_author(rev))