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"""
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
262
358
class TestLongLogFormatter(TestCaseWithTransport):
492
588
self.assertEqualDiff(log_contents,
493
589
'1: Line-Log-Formatte... 2005-11-23 add a\n')
495
def test_short_log_with_merges(self):
496
wt = self.make_branch_and_memory_tree('.')
500
wt.commit('rev-1', rev_id='rev-1',
501
timestamp=1132586655, timezone=36000,
502
committer='Joe Foo <joe@foo.com>')
503
wt.commit('rev-merged', rev_id='rev-2a',
504
timestamp=1132586700, timezone=36000,
505
committer='Joe Foo <joe@foo.com>')
506
wt.set_parent_ids(['rev-1', 'rev-2a'])
507
wt.branch.set_last_revision_info(1, 'rev-1')
508
wt.commit('rev-2', rev_id='rev-2b',
509
timestamp=1132586800, timezone=36000,
510
committer='Joe Foo <joe@foo.com>')
511
logfile = self.make_utf8_encoded_stringio()
512
formatter = ShortLogFormatter(to_file=logfile)
513
show_log(wt.branch, formatter)
515
self.assertEqualDiff(logfile.getvalue(), """\
516
2 Joe Foo\t2005-11-22 [merge]
519
1 Joe Foo\t2005-11-22
526
591
def test_trailing_newlines(self):
527
592
wt = self.make_branch_and_tree('.')
528
593
b = make_commits_with_trailing_newlines(wt)
535
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
539
633
class TestGetViewRevisions(TestCaseWithTransport):
808
902
rev.committer = 'John Doe <jdoe@example.com>'
809
903
lf = LogFormatter(None)
810
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))
812
916
def test_short_author(self):
813
917
rev = Revision('a-id')
816
920
self.assertEqual('John Doe', lf.short_author(rev))
817
921
rev.properties['author'] = 'John Smith <jsmith@example.com>'
818
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))