~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_log.py

  • Committer: Robert Collins
  • Date: 2010-04-08 04:34:03 UTC
  • mfrom: (5138 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5139.
  • Revision ID: robertc@robertcollins.net-20100408043403-56z0d07vdqrx7f3t
Update bugfix for 528114 to trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
    registry,
24
24
    revision,
25
25
    revisionspec,
 
26
    symbol_versioning,
26
27
    tests,
27
28
    )
28
29
 
29
30
 
30
 
class TestCaseForLogFormatter(tests.TestCaseWithTransport):
 
31
class TestLogMixin(object):
 
32
 
 
33
    def wt_commit(self, wt, message, **kwargs):
 
34
        """Use some mostly fixed values for commits to simplify tests.
 
35
 
 
36
        Tests can use this function to get some commit attributes. The time
 
37
        stamp is incremented at each commit.
 
38
        """
 
39
        if getattr(self, 'timestamp', None) is None:
 
40
            self.timestamp = 1132617600 # Mon 2005-11-22 00:00:00 +0000
 
41
        else:
 
42
            self.timestamp += 1 # 1 second between each commit
 
43
        kwargs.setdefault('timestamp', self.timestamp)
 
44
        kwargs.setdefault('timezone', 0) # UTC
 
45
        kwargs.setdefault('committer', 'Joe Foo <joe@foo.com>')
 
46
 
 
47
        return wt.commit(message, **kwargs)
 
48
 
 
49
 
 
50
class TestCaseForLogFormatter(tests.TestCaseWithTransport, TestLogMixin):
31
51
 
32
52
    def setUp(self):
33
53
        super(TestCaseForLogFormatter, self).setUp()
41
61
        self.addCleanup(restore)
42
62
 
43
63
    def assertFormatterResult(self, result, branch, formatter_class,
44
 
                              formatter_kwargs=None, show_log_kwargs=None,
45
 
                              normalize=False):
 
64
                              formatter_kwargs=None, show_log_kwargs=None):
46
65
        logfile = self.make_utf8_encoded_stringio()
47
66
        if formatter_kwargs is None:
48
67
            formatter_kwargs = {}
50
69
        if show_log_kwargs is None:
51
70
            show_log_kwargs = {}
52
71
        log.show_log(branch, formatter, **show_log_kwargs)
53
 
        log_content = logfile.getvalue()
54
 
        if normalize:
55
 
            log_content = normalize_log(log_content)
56
 
        self.assertEqualDiff(result, log_content)
 
72
        self.assertEqualDiff(result, logfile.getvalue())
57
73
 
58
74
    def make_standard_commit(self, branch_nick, **kwargs):
59
75
        wt = self.make_branch_and_tree('.')
62
78
        self.build_tree(['a'])
63
79
        wt.add(['a'])
64
80
        wt.branch.nick = branch_nick
65
 
        kwargs = dict(kwargs)
66
 
        kwargs.setdefault('message', 'add a')
67
 
        kwargs.setdefault('timestamp', 1132711707)
68
 
        kwargs.setdefault('timezone', 36000)
69
81
        kwargs.setdefault('committer', 'Lorem Ipsum <test@example.com>')
70
82
        kwargs.setdefault('authors', ['John Doe <jdoe@example.com>'])
71
 
        wt.commit(**kwargs)
 
83
        self.wt_commit(wt, 'add a', **kwargs)
72
84
        return wt
73
85
 
 
86
    def make_commits_with_trailing_newlines(self, wt):
 
87
        """Helper method for LogFormatter tests"""
 
88
        b = wt.branch
 
89
        b.nick = 'test'
 
90
        self.build_tree_contents([('a', 'hello moto\n')])
 
91
        self.wt_commit(wt, 'simple log message', rev_id='a1')
 
92
        self.build_tree_contents([('b', 'goodbye\n')])
 
93
        wt.add('b')
 
94
        self.wt_commit(wt, 'multiline\nlog\nmessage\n', rev_id='a2')
 
95
 
 
96
        self.build_tree_contents([('c', 'just another manic monday\n')])
 
97
        wt.add('c')
 
98
        self.wt_commit(wt, 'single line with trailing newline\n', rev_id='a3')
 
99
        return b
 
100
 
74
101
    def _prepare_tree_with_merges(self, with_tags=False):
75
102
        wt = self.make_branch_and_memory_tree('.')
76
103
        wt.lock_write()
77
104
        self.addCleanup(wt.unlock)
78
105
        wt.add('')
79
 
        wt.commit('rev-1', rev_id='rev-1',
80
 
                  timestamp=1132586655, timezone=36000,
81
 
                  committer='Joe Foo <joe@foo.com>')
82
 
        wt.commit('rev-merged', rev_id='rev-2a',
83
 
                  timestamp=1132586700, timezone=36000,
84
 
                  committer='Joe Foo <joe@foo.com>')
 
106
        self.wt_commit(wt, 'rev-1', rev_id='rev-1')
 
107
        self.wt_commit(wt, 'rev-merged', rev_id='rev-2a')
85
108
        wt.set_parent_ids(['rev-1', 'rev-2a'])
86
109
        wt.branch.set_last_revision_info(1, 'rev-1')
87
 
        wt.commit('rev-2', rev_id='rev-2b',
88
 
                  timestamp=1132586800, timezone=36000,
89
 
                  committer='Joe Foo <joe@foo.com>')
 
110
        self.wt_commit(wt, 'rev-2', rev_id='rev-2b')
90
111
        if with_tags:
91
112
            branch = wt.branch
92
113
            branch.tags.set_tag('v0.2', 'rev-2b')
93
 
            wt.commit('rev-3', rev_id='rev-3',
94
 
                      timestamp=1132586900, timezone=36000,
95
 
                      committer='Jane Foo <jane@foo.com>')
 
114
            self.wt_commit(wt, 'rev-3', rev_id='rev-3')
96
115
            branch.tags.set_tag('v1.0rc1', 'rev-3')
97
116
            branch.tags.set_tag('v1.0', 'rev-3')
98
117
        return wt
99
118
 
100
 
        
101
 
 
102
 
 
103
119
class LogCatcher(log.LogFormatter):
104
120
    """Pull log messages into a list rather than displaying them.
105
121
 
108
124
    being dependent on the formatting.
109
125
    """
110
126
 
 
127
    supports_merge_revisions = True
111
128
    supports_delta = True
 
129
    supports_diff = True
 
130
    preferred_levels = 0
112
131
 
113
 
    def __init__(self):
114
 
        super(LogCatcher, self).__init__(to_file=None)
 
132
    def __init__(self, *args, **kwargs):
 
133
        kwargs.update(dict(to_file=None))
 
134
        super(LogCatcher, self).__init__(*args, **kwargs)
115
135
        self.revisions = []
116
136
 
117
137
    def log_revision(self, revision):
260
280
        self.checkDelta(logentry.delta, added=['file1', 'file2'])
261
281
 
262
282
 
263
 
def make_commits_with_trailing_newlines(wt):
264
 
    """Helper method for LogFormatter tests"""
265
 
    b = wt.branch
266
 
    b.nick='test'
267
 
    open('a', 'wb').write('hello moto\n')
268
 
    wt.add('a')
269
 
    wt.commit('simple log message', rev_id='a1',
270
 
              timestamp=1132586655.459960938, timezone=-6*3600,
271
 
              committer='Joe Foo <joe@foo.com>')
272
 
    open('b', 'wb').write('goodbye\n')
273
 
    wt.add('b')
274
 
    wt.commit('multiline\nlog\nmessage\n', rev_id='a2',
275
 
              timestamp=1132586842.411175966, timezone=-6*3600,
276
 
              committer='Joe Foo <joe@foo.com>',
277
 
              authors=['Joe Bar <joe@bar.com>'])
278
 
 
279
 
    open('c', 'wb').write('just another manic monday\n')
280
 
    wt.add('c')
281
 
    wt.commit('single line with trailing newline\n', rev_id='a3',
282
 
              timestamp=1132587176.835228920, timezone=-6*3600,
283
 
              committer = 'Joe Foo <joe@foo.com>')
284
 
    return b
285
 
 
286
 
 
287
 
def normalize_log(log):
288
 
    """Replaces the variable lines of logs with fixed lines"""
289
 
    author = 'author: Dolor Sit <test@example.com>'
290
 
    committer = 'committer: Lorem Ipsum <test@example.com>'
291
 
    lines = log.splitlines(True)
292
 
    for idx,line in enumerate(lines):
293
 
        stripped_line = line.lstrip()
294
 
        indent = ' ' * (len(line) - len(stripped_line))
295
 
        if stripped_line.startswith('author:'):
296
 
            lines[idx] = indent + author + '\n'
297
 
        elif stripped_line.startswith('committer:'):
298
 
            lines[idx] = indent + committer + '\n'
299
 
        elif stripped_line.startswith('timestamp:'):
300
 
            lines[idx] = indent + 'timestamp: Just now\n'
301
 
    return ''.join(lines)
302
 
 
303
 
 
304
283
class TestShortLogFormatter(TestCaseForLogFormatter):
305
284
 
306
285
    def test_trailing_newlines(self):
307
286
        wt = self.make_branch_and_tree('.')
308
 
        b = make_commits_with_trailing_newlines(wt)
 
287
        b = self.make_commits_with_trailing_newlines(wt)
309
288
        self.assertFormatterResult("""\
310
 
    3 Joe Foo\t2005-11-21
 
289
    3 Joe Foo\t2005-11-22
311
290
      single line with trailing newline
312
291
 
313
 
    2 Joe Bar\t2005-11-21
 
292
    2 Joe Foo\t2005-11-22
314
293
      multiline
315
294
      log
316
295
      message
317
296
 
318
 
    1 Joe Foo\t2005-11-21
 
297
    1 Joe Foo\t2005-11-22
319
298
      simple log message
320
299
 
321
300
""",
348
327
            formatter_kwargs=dict(show_advice=True))
349
328
 
350
329
    def test_short_log_with_merges_and_range(self):
351
 
        wt = self.make_branch_and_memory_tree('.')
352
 
        wt.lock_write()
353
 
        self.addCleanup(wt.unlock)
354
 
        wt.add('')
355
 
        wt.commit('rev-1', rev_id='rev-1',
356
 
                  timestamp=1132586655, timezone=36000,
357
 
                  committer='Joe Foo <joe@foo.com>')
358
 
        wt.commit('rev-merged', rev_id='rev-2a',
359
 
                  timestamp=1132586700, timezone=36000,
360
 
                  committer='Joe Foo <joe@foo.com>')
361
 
        wt.branch.set_last_revision_info(1, 'rev-1')
362
 
        wt.set_parent_ids(['rev-1', 'rev-2a'])
363
 
        wt.commit('rev-2b', rev_id='rev-2b',
364
 
                  timestamp=1132586800, timezone=36000,
365
 
                  committer='Joe Foo <joe@foo.com>')
366
 
        wt.commit('rev-3a', rev_id='rev-3a',
367
 
                  timestamp=1132586800, timezone=36000,
368
 
                  committer='Joe Foo <joe@foo.com>')
 
330
        wt = self._prepare_tree_with_merges()
 
331
        self.wt_commit(wt, 'rev-3a', rev_id='rev-3a')
369
332
        wt.branch.set_last_revision_info(2, 'rev-2b')
370
333
        wt.set_parent_ids(['rev-2b', 'rev-3a'])
371
 
        wt.commit('rev-3b', rev_id='rev-3b',
372
 
                  timestamp=1132586800, timezone=36000,
373
 
                  committer='Joe Foo <joe@foo.com>')
 
334
        self.wt_commit(wt, 'rev-3b', rev_id='rev-3b')
374
335
        self.assertFormatterResult("""\
375
336
    3 Joe Foo\t2005-11-22 [merge]
376
337
      rev-3b
377
338
 
378
339
    2 Joe Foo\t2005-11-22 [merge]
379
 
      rev-2b
 
340
      rev-2
380
341
 
381
342
""",
382
343
            wt.branch, log.ShortLogFormatter,
385
346
    def test_short_log_with_tags(self):
386
347
        wt = self._prepare_tree_with_merges(with_tags=True)
387
348
        self.assertFormatterResult("""\
388
 
    3 Jane Foo\t2005-11-22 {v1.0, v1.0rc1}
 
349
    3 Joe Foo\t2005-11-22 {v1.0, v1.0rc1}
389
350
      rev-3
390
351
 
391
352
    2 Joe Foo\t2005-11-22 {v0.2} [merge]
398
359
            wt.branch, log.ShortLogFormatter)
399
360
 
400
361
    def test_short_log_single_merge_revision(self):
401
 
        wt = self.make_branch_and_memory_tree('.')
402
 
        wt.lock_write()
403
 
        self.addCleanup(wt.unlock)
404
 
        wt.add('')
405
 
        wt.commit('rev-1', rev_id='rev-1',
406
 
                  timestamp=1132586655, timezone=36000,
407
 
                  committer='Joe Foo <joe@foo.com>')
408
 
        wt.commit('rev-merged', rev_id='rev-2a',
409
 
                  timestamp=1132586700, timezone=36000,
410
 
                  committer='Joe Foo <joe@foo.com>')
411
 
        wt.set_parent_ids(['rev-1', 'rev-2a'])
412
 
        wt.branch.set_last_revision_info(1, 'rev-1')
413
 
        wt.commit('rev-2', rev_id='rev-2b',
414
 
                  timestamp=1132586800, timezone=36000,
415
 
                  committer='Joe Foo <joe@foo.com>')
 
362
        wt = self._prepare_tree_with_merges()
416
363
        revspec = revisionspec.RevisionSpec.from_string('1.1.1')
417
364
        rev = revspec.in_history(wt.branch)
418
365
        self.assertFormatterResult("""\
427
374
class TestShortLogFormatterWithMergeRevisions(TestCaseForLogFormatter):
428
375
 
429
376
    def test_short_merge_revs_log_with_merges(self):
430
 
        wt = self.make_branch_and_memory_tree('.')
431
 
        wt.lock_write()
432
 
        self.addCleanup(wt.unlock)
433
 
        wt.add('')
434
 
        wt.commit('rev-1', rev_id='rev-1',
435
 
                  timestamp=1132586655, timezone=36000,
436
 
                  committer='Joe Foo <joe@foo.com>')
437
 
        wt.commit('rev-merged', rev_id='rev-2a',
438
 
                  timestamp=1132586700, timezone=36000,
439
 
                  committer='Joe Foo <joe@foo.com>')
440
 
        wt.set_parent_ids(['rev-1', 'rev-2a'])
441
 
        wt.branch.set_last_revision_info(1, 'rev-1')
442
 
        wt.commit('rev-2', rev_id='rev-2b',
443
 
                  timestamp=1132586800, timezone=36000,
444
 
                  committer='Joe Foo <joe@foo.com>')
 
377
        wt = self._prepare_tree_with_merges()
445
378
        # Note that the 1.1.1 indenting is in fact correct given that
446
379
        # the revision numbers are right justified within 5 characters
447
380
        # for mainline revnos and 9 characters for dotted revnos.
460
393
            formatter_kwargs=dict(levels=0))
461
394
 
462
395
    def test_short_merge_revs_log_single_merge_revision(self):
463
 
        wt = self.make_branch_and_memory_tree('.')
464
 
        wt.lock_write()
465
 
        self.addCleanup(wt.unlock)
466
 
        wt.add('')
467
 
        wt.commit('rev-1', rev_id='rev-1',
468
 
                  timestamp=1132586655, timezone=36000,
469
 
                  committer='Joe Foo <joe@foo.com>')
470
 
        wt.commit('rev-merged', rev_id='rev-2a',
471
 
                  timestamp=1132586700, timezone=36000,
472
 
                  committer='Joe Foo <joe@foo.com>')
473
 
        wt.set_parent_ids(['rev-1', 'rev-2a'])
474
 
        wt.branch.set_last_revision_info(1, 'rev-1')
475
 
        wt.commit('rev-2', rev_id='rev-2b',
476
 
                  timestamp=1132586800, timezone=36000,
477
 
                  committer='Joe Foo <joe@foo.com>')
 
396
        wt = self._prepare_tree_with_merges()
478
397
        revspec = revisionspec.RevisionSpec.from_string('1.1.1')
479
398
        rev = revspec.in_history(wt.branch)
480
399
        self.assertFormatterResult("""\
500
419
revno: 1
501
420
committer: Lorem Ipsum <test@example.com>
502
421
branch nick: test_verbose_log
503
 
timestamp: Wed 2005-11-23 12:08:27 +1000
 
422
timestamp: Tue 2005-11-22 00:00:00 +0000
504
423
message:
505
424
  add a
506
425
added:
511
430
 
512
431
    def test_merges_are_indented_by_level(self):
513
432
        wt = self.make_branch_and_tree('parent')
514
 
        wt.commit('first post')
515
 
        self.run_bzr('branch parent child')
516
 
        self.run_bzr(['commit', '-m', 'branch 1', '--unchanged', 'child'])
517
 
        self.run_bzr('branch child smallerchild')
518
 
        self.run_bzr(['commit', '-m', 'branch 2', '--unchanged',
519
 
            'smallerchild'])
520
 
        os.chdir('child')
521
 
        self.run_bzr('merge ../smallerchild')
522
 
        self.run_bzr(['commit', '-m', 'merge branch 2'])
523
 
        os.chdir('../parent')
524
 
        self.run_bzr('merge ../child')
525
 
        wt.commit('merge branch 1')
 
433
        self.wt_commit(wt, 'first post')
 
434
        child_wt = wt.bzrdir.sprout('child').open_workingtree()
 
435
        self.wt_commit(child_wt, 'branch 1')
 
436
        smallerchild_wt = wt.bzrdir.sprout('smallerchild').open_workingtree()
 
437
        self.wt_commit(smallerchild_wt, 'branch 2')
 
438
        child_wt.merge_from_branch(smallerchild_wt.branch)
 
439
        self.wt_commit(child_wt, 'merge branch 2')
 
440
        wt.merge_from_branch(child_wt.branch)
 
441
        self.wt_commit(wt, 'merge branch 1')
526
442
        self.assertFormatterResult("""\
527
443
------------------------------------------------------------
528
444
revno: 2 [merge]
529
 
committer: Lorem Ipsum <test@example.com>
 
445
committer: Joe Foo <joe@foo.com>
530
446
branch nick: parent
531
 
timestamp: Just now
 
447
timestamp: Tue 2005-11-22 00:00:04 +0000
532
448
message:
533
449
  merge branch 1
534
450
    ------------------------------------------------------------
535
451
    revno: 1.1.2 [merge]
536
 
    committer: Lorem Ipsum <test@example.com>
 
452
    committer: Joe Foo <joe@foo.com>
537
453
    branch nick: child
538
 
    timestamp: Just now
 
454
    timestamp: Tue 2005-11-22 00:00:03 +0000
539
455
    message:
540
456
      merge branch 2
541
457
        ------------------------------------------------------------
542
458
        revno: 1.2.1
543
 
        committer: Lorem Ipsum <test@example.com>
 
459
        committer: Joe Foo <joe@foo.com>
544
460
        branch nick: smallerchild
545
 
        timestamp: Just now
 
461
        timestamp: Tue 2005-11-22 00:00:02 +0000
546
462
        message:
547
463
          branch 2
548
464
    ------------------------------------------------------------
549
465
    revno: 1.1.1
550
 
    committer: Lorem Ipsum <test@example.com>
 
466
    committer: Joe Foo <joe@foo.com>
551
467
    branch nick: child
552
 
    timestamp: Just now
 
468
    timestamp: Tue 2005-11-22 00:00:01 +0000
553
469
    message:
554
470
      branch 1
555
471
------------------------------------------------------------
556
472
revno: 1
557
 
committer: Lorem Ipsum <test@example.com>
 
473
committer: Joe Foo <joe@foo.com>
558
474
branch nick: parent
559
 
timestamp: Just now
 
475
timestamp: Tue 2005-11-22 00:00:00 +0000
560
476
message:
561
477
  first post
562
478
""",
563
479
            wt.branch, log.LongLogFormatter,
564
480
            formatter_kwargs=dict(levels=0),
565
 
            show_log_kwargs=dict(verbose=True),
566
 
            normalize=True)
 
481
            show_log_kwargs=dict(verbose=True))
567
482
 
568
483
    def test_verbose_merge_revisions_contain_deltas(self):
569
484
        wt = self.make_branch_and_tree('parent')
570
485
        self.build_tree(['parent/f1', 'parent/f2'])
571
486
        wt.add(['f1','f2'])
572
 
        wt.commit('first post')
573
 
        self.run_bzr('branch parent child')
 
487
        self.wt_commit(wt, 'first post')
 
488
        child_wt = wt.bzrdir.sprout('child').open_workingtree()
574
489
        os.unlink('child/f1')
575
 
        file('child/f2', 'wb').write('hello\n')
576
 
        self.run_bzr(['commit', '-m', 'removed f1 and modified f2',
577
 
            'child'])
578
 
        os.chdir('parent')
579
 
        self.run_bzr('merge ../child')
580
 
        wt.commit('merge branch 1')
 
490
        self.build_tree_contents([('child/f2', 'hello\n')])
 
491
        self.wt_commit(child_wt, 'removed f1 and modified f2')
 
492
        wt.merge_from_branch(child_wt.branch)
 
493
        self.wt_commit(wt, 'merge branch 1')
581
494
        self.assertFormatterResult("""\
582
495
------------------------------------------------------------
583
496
revno: 2 [merge]
584
 
committer: Lorem Ipsum <test@example.com>
 
497
committer: Joe Foo <joe@foo.com>
585
498
branch nick: parent
586
 
timestamp: Just now
 
499
timestamp: Tue 2005-11-22 00:00:02 +0000
587
500
message:
588
501
  merge branch 1
589
502
removed:
592
505
  f2
593
506
    ------------------------------------------------------------
594
507
    revno: 1.1.1
595
 
    committer: Lorem Ipsum <test@example.com>
 
508
    committer: Joe Foo <joe@foo.com>
596
509
    branch nick: child
597
 
    timestamp: Just now
 
510
    timestamp: Tue 2005-11-22 00:00:01 +0000
598
511
    message:
599
512
      removed f1 and modified f2
600
513
    removed:
603
516
      f2
604
517
------------------------------------------------------------
605
518
revno: 1
606
 
committer: Lorem Ipsum <test@example.com>
 
519
committer: Joe Foo <joe@foo.com>
607
520
branch nick: parent
608
 
timestamp: Just now
 
521
timestamp: Tue 2005-11-22 00:00:00 +0000
609
522
message:
610
523
  first post
611
524
added:
614
527
""",
615
528
            wt.branch, log.LongLogFormatter,
616
529
            formatter_kwargs=dict(levels=0),
617
 
            show_log_kwargs=dict(verbose=True),
618
 
            normalize=True)
 
530
            show_log_kwargs=dict(verbose=True))
619
531
 
620
532
    def test_trailing_newlines(self):
621
533
        wt = self.make_branch_and_tree('.')
622
 
        b = make_commits_with_trailing_newlines(wt)
 
534
        b = self.make_commits_with_trailing_newlines(wt)
623
535
        self.assertFormatterResult("""\
624
536
------------------------------------------------------------
625
537
revno: 3
626
538
committer: Joe Foo <joe@foo.com>
627
539
branch nick: test
628
 
timestamp: Mon 2005-11-21 09:32:56 -0600
 
540
timestamp: Tue 2005-11-22 00:00:02 +0000
629
541
message:
630
542
  single line with trailing newline
631
543
------------------------------------------------------------
632
544
revno: 2
633
 
author: Joe Bar <joe@bar.com>
634
545
committer: Joe Foo <joe@foo.com>
635
546
branch nick: test
636
 
timestamp: Mon 2005-11-21 09:27:22 -0600
 
547
timestamp: Tue 2005-11-22 00:00:01 +0000
637
548
message:
638
549
  multiline
639
550
  log
642
553
revno: 1
643
554
committer: Joe Foo <joe@foo.com>
644
555
branch nick: test
645
 
timestamp: Mon 2005-11-21 09:24:15 -0600
 
556
timestamp: Tue 2005-11-22 00:00:00 +0000
646
557
message:
647
558
  simple log message
648
559
""",
661
572
author: John Doe <jdoe@example.com>, Jane Rey <jrey@example.com>
662
573
committer: Lorem Ipsum <test@example.com>
663
574
branch nick: test_author_log
664
 
timestamp: Wed 2005-11-23 12:08:27 +1000
 
575
timestamp: Tue 2005-11-22 00:00:00 +0000
665
576
message:
666
577
  add a
667
578
""",
686
597
author: John Doe <jdoe@example.com>
687
598
committer: Lorem Ipsum <test@example.com>
688
599
branch nick: test_properties_in_log
689
 
timestamp: Wed 2005-11-23 12:08:27 +1000
 
600
timestamp: Tue 2005-11-22 00:00:00 +0000
690
601
message:
691
602
  add a
692
603
""",
704
615
            'trivial_custom_prop_handler',
705
616
            trivial_custom_prop_handler)
706
617
        self.assertFormatterResult("""\
707
 
    1 John Doe\t2005-11-23
 
618
    1 John Doe\t2005-11-22
708
619
      test_prop: test_value
709
620
      add a
710
621
 
761
672
revno: 1
762
673
committer: Lorem Ipsum <test@example.com>
763
674
branch nick: test_long_verbose_log
764
 
timestamp: Wed 2005-11-23 12:08:27 +1000
 
675
timestamp: Tue 2005-11-22 00:00:00 +0000
765
676
message:
766
677
  add a
767
678
added:
775
686
        wt = self.make_branch_and_tree('parent')
776
687
        self.build_tree(['parent/f1', 'parent/f2'])
777
688
        wt.add(['f1','f2'])
778
 
        wt.commit('first post')
 
689
        self.wt_commit(wt, 'first post')
779
690
        child_wt = wt.bzrdir.sprout('child').open_workingtree()
780
691
        os.unlink('child/f1')
781
692
        self.build_tree_contents([('child/f2', 'hello\n')])
782
 
        child_wt.commit('removed f1 and modified f2')
 
693
        self.wt_commit(child_wt, 'removed f1 and modified f2')
783
694
        wt.merge_from_branch(child_wt.branch)
784
 
        wt.commit('merge branch 1')
 
695
        self.wt_commit(wt, 'merge branch 1')
785
696
        self.assertFormatterResult("""\
786
697
------------------------------------------------------------
787
698
revno: 2 [merge]
788
 
committer: Lorem Ipsum <test@example.com>
 
699
committer: Joe Foo <joe@foo.com>
789
700
branch nick: parent
790
 
timestamp: Just now
 
701
timestamp: Tue 2005-11-22 00:00:02 +0000
791
702
message:
792
703
  merge branch 1
793
704
removed:
796
707
  f2
797
708
------------------------------------------------------------
798
709
revno: 1
799
 
committer: Lorem Ipsum <test@example.com>
 
710
committer: Joe Foo <joe@foo.com>
800
711
branch nick: parent
801
 
timestamp: Just now
 
712
timestamp: Tue 2005-11-22 00:00:00 +0000
802
713
message:
803
714
  first post
804
715
added:
807
718
""",
808
719
            wt.branch, log.LongLogFormatter,
809
720
            formatter_kwargs=dict(levels=1),
810
 
            show_log_kwargs=dict(verbose=True),
811
 
            normalize=True)
 
721
            show_log_kwargs=dict(verbose=True))
812
722
 
813
723
    def test_long_trailing_newlines(self):
814
724
        wt = self.make_branch_and_tree('.')
815
 
        b = make_commits_with_trailing_newlines(wt)
 
725
        b = self.make_commits_with_trailing_newlines(wt)
816
726
        self.assertFormatterResult("""\
817
727
------------------------------------------------------------
818
728
revno: 3
819
729
committer: Joe Foo <joe@foo.com>
820
730
branch nick: test
821
 
timestamp: Mon 2005-11-21 09:32:56 -0600
 
731
timestamp: Tue 2005-11-22 00:00:02 +0000
822
732
message:
823
733
  single line with trailing newline
824
734
------------------------------------------------------------
825
735
revno: 2
826
 
author: Joe Bar <joe@bar.com>
827
736
committer: Joe Foo <joe@foo.com>
828
737
branch nick: test
829
 
timestamp: Mon 2005-11-21 09:27:22 -0600
 
738
timestamp: Tue 2005-11-22 00:00:01 +0000
830
739
message:
831
740
  multiline
832
741
  log
835
744
revno: 1
836
745
committer: Joe Foo <joe@foo.com>
837
746
branch nick: test
838
 
timestamp: Mon 2005-11-21 09:24:15 -0600
 
747
timestamp: Tue 2005-11-22 00:00:00 +0000
839
748
message:
840
749
  simple log message
841
750
""",
853
762
author: John Doe <jdoe@example.com>
854
763
committer: Lorem Ipsum <test@example.com>
855
764
branch nick: test_author_log
856
 
timestamp: Wed 2005-11-23 12:08:27 +1000
 
765
timestamp: Tue 2005-11-22 00:00:00 +0000
857
766
message:
858
767
  add a
859
768
""",
878
787
author: John Doe <jdoe@example.com>
879
788
committer: Lorem Ipsum <test@example.com>
880
789
branch nick: test_properties_in_log
881
 
timestamp: Wed 2005-11-23 12:08:27 +1000
 
790
timestamp: Tue 2005-11-22 00:00:00 +0000
882
791
message:
883
792
  add a
884
793
""",
897
806
                committer='Line-Log-Formatter Tester <test@line.log>',
898
807
                authors=[])
899
808
        self.assertFormatterResult("""\
900
 
1: Line-Log-Formatte... 2005-11-23 add a
 
809
1: Line-Log-Formatte... 2005-11-22 add a
901
810
""",
902
811
            wt.branch, log.LineLogFormatter)
903
812
 
904
813
    def test_trailing_newlines(self):
905
814
        wt = self.make_branch_and_tree('.')
906
 
        b = make_commits_with_trailing_newlines(wt)
 
815
        b = self.make_commits_with_trailing_newlines(wt)
907
816
        self.assertFormatterResult("""\
908
 
3: Joe Foo 2005-11-21 single line with trailing newline
909
 
2: Joe Bar 2005-11-21 multiline
910
 
1: Joe Foo 2005-11-21 simple log message
 
817
3: Joe Foo 2005-11-22 single line with trailing newline
 
818
2: Joe Foo 2005-11-22 multiline
 
819
1: Joe Foo 2005-11-22 simple log message
911
820
""",
912
821
            b, log.LineLogFormatter)
913
822
 
924
833
    def test_line_log_with_tags(self):
925
834
        wt = self._prepare_tree_with_merges(with_tags=True)
926
835
        self.assertFormatterResult("""\
927
 
3: Jane Foo 2005-11-22 {v1.0, v1.0rc1} rev-3
 
836
3: Joe Foo 2005-11-22 {v1.0, v1.0rc1} rev-3
928
837
2: Joe Foo 2005-11-22 [merge] {v0.2} rev-2
929
838
1: Joe Foo 2005-11-22 rev-1
930
839
""",
942
851
                committer='Line-Log-Formatter Tester <test@line.log>',
943
852
                authors=[])
944
853
        self.assertFormatterResult("""\
945
 
1: Line-Log-Formatte... 2005-11-23 add a
 
854
1: Line-Log-Formatte... 2005-11-22 add a
946
855
""",
947
856
            wt.branch, log.LineLogFormatter)
948
857
 
949
858
    def test_line_merge_revs_log_single_merge_revision(self):
950
 
        wt = self.make_branch_and_memory_tree('.')
951
 
        wt.lock_write()
952
 
        self.addCleanup(wt.unlock)
953
 
        wt.add('')
954
 
        wt.commit('rev-1', rev_id='rev-1',
955
 
                  timestamp=1132586655, timezone=36000,
956
 
                  committer='Joe Foo <joe@foo.com>')
957
 
        wt.commit('rev-merged', rev_id='rev-2a',
958
 
                  timestamp=1132586700, timezone=36000,
959
 
                  committer='Joe Foo <joe@foo.com>')
960
 
        wt.set_parent_ids(['rev-1', 'rev-2a'])
961
 
        wt.branch.set_last_revision_info(1, 'rev-1')
962
 
        wt.commit('rev-2', rev_id='rev-2b',
963
 
                  timestamp=1132586800, timezone=36000,
964
 
                  committer='Joe Foo <joe@foo.com>')
 
859
        wt = self._prepare_tree_with_merges()
965
860
        revspec = revisionspec.RevisionSpec.from_string('1.1.1')
966
861
        rev = revspec.in_history(wt.branch)
967
862
        self.assertFormatterResult("""\
972
867
            show_log_kwargs=dict(start_revision=rev, end_revision=rev))
973
868
 
974
869
    def test_line_merge_revs_log_with_merges(self):
975
 
        wt = self.make_branch_and_memory_tree('.')
976
 
        wt.lock_write()
977
 
        self.addCleanup(wt.unlock)
978
 
        wt.add('')
979
 
        wt.commit('rev-1', rev_id='rev-1',
980
 
                  timestamp=1132586655, timezone=36000,
981
 
                  committer='Joe Foo <joe@foo.com>')
982
 
        wt.commit('rev-merged', rev_id='rev-2a',
983
 
                  timestamp=1132586700, timezone=36000,
984
 
                  committer='Joe Foo <joe@foo.com>')
985
 
        wt.set_parent_ids(['rev-1', 'rev-2a'])
986
 
        wt.branch.set_last_revision_info(1, 'rev-1')
987
 
        wt.commit('rev-2', rev_id='rev-2b',
988
 
                  timestamp=1132586800, timezone=36000,
989
 
                  committer='Joe Foo <joe@foo.com>')
 
870
        wt = self._prepare_tree_with_merges()
990
871
        self.assertFormatterResult("""\
991
872
2: Joe Foo 2005-11-22 [merge] rev-2
992
873
  1.1.1: Joe Foo 2005-11-22 rev-merged
996
877
            formatter_kwargs=dict(levels=0))
997
878
 
998
879
 
999
 
class TestGetViewRevisions(tests.TestCaseWithTransport):
 
880
class TestGnuChangelogFormatter(TestCaseForLogFormatter):
 
881
 
 
882
    def test_gnu_changelog(self):
 
883
        wt = self.make_standard_commit('nicky', authors=[])
 
884
        self.assertFormatterResult('''\
 
885
2005-11-22  Lorem Ipsum  <test@example.com>
 
886
 
 
887
\tadd a
 
888
 
 
889
''',
 
890
            wt.branch, log.GnuChangelogLogFormatter)
 
891
 
 
892
    def test_with_authors(self):
 
893
        wt = self.make_standard_commit('nicky',
 
894
            authors=['Fooa Fooz <foo@example.com>',
 
895
                     'Bari Baro <bar@example.com>'])
 
896
        self.assertFormatterResult('''\
 
897
2005-11-22  Fooa Fooz  <foo@example.com>
 
898
 
 
899
\tadd a
 
900
 
 
901
''',
 
902
            wt.branch, log.GnuChangelogLogFormatter)
 
903
 
 
904
    def test_verbose(self):
 
905
        wt = self.make_standard_commit('nicky')
 
906
        self.assertFormatterResult('''\
 
907
2005-11-22  John Doe  <jdoe@example.com>
 
908
 
 
909
\t* a:
 
910
 
 
911
\tadd a
 
912
 
 
913
''',
 
914
            wt.branch, log.GnuChangelogLogFormatter,
 
915
            show_log_kwargs=dict(verbose=True))
 
916
 
 
917
class TestGetViewRevisions(tests.TestCaseWithTransport, TestLogMixin):
 
918
 
 
919
    def _get_view_revisions(self, *args, **kwargs):
 
920
        return self.applyDeprecated(symbol_versioning.deprecated_in((2, 2, 0)),
 
921
                                    log.get_view_revisions, *args, **kwargs)
1000
922
 
1001
923
    def make_tree_with_commits(self):
1002
924
        """Create a tree with well-known revision ids"""
1003
925
        wt = self.make_branch_and_tree('tree1')
1004
 
        wt.commit('commit one', rev_id='1')
1005
 
        wt.commit('commit two', rev_id='2')
1006
 
        wt.commit('commit three', rev_id='3')
 
926
        self.wt_commit(wt, 'commit one', rev_id='1')
 
927
        self.wt_commit(wt, 'commit two', rev_id='2')
 
928
        self.wt_commit(wt, 'commit three', rev_id='3')
1007
929
        mainline_revs = [None, '1', '2', '3']
1008
930
        rev_nos = {'1': 1, '2': 2, '3': 3}
1009
931
        return mainline_revs, rev_nos, wt
1012
934
        """Create a tree with well-known revision ids and a merge"""
1013
935
        mainline_revs, rev_nos, wt = self.make_tree_with_commits()
1014
936
        tree2 = wt.bzrdir.sprout('tree2').open_workingtree()
1015
 
        tree2.commit('four-a', rev_id='4a')
 
937
        self.wt_commit(tree2, 'four-a', rev_id='4a')
1016
938
        wt.merge_from_branch(tree2.branch)
1017
 
        wt.commit('four-b', rev_id='4b')
 
939
        self.wt_commit(wt, 'four-b', rev_id='4b')
1018
940
        mainline_revs.append('4b')
1019
941
        rev_nos['4b'] = 4
1020
942
        # 4a: 3.1.1
1068
990
        mainline_revs, rev_nos, wt = self.make_tree_with_commits()
1069
991
        wt.lock_read()
1070
992
        self.addCleanup(wt.unlock)
1071
 
        revisions = list(log.get_view_revisions(
 
993
        revisions = list(self._get_view_revisions(
1072
994
                mainline_revs, rev_nos, wt.branch, 'forward'))
1073
995
        self.assertEqual([('1', '1', 0), ('2', '2', 0), ('3', '3', 0)],
1074
996
                         revisions)
1075
 
        revisions2 = list(log.get_view_revisions(
 
997
        revisions2 = list(self._get_view_revisions(
1076
998
                mainline_revs, rev_nos, wt.branch, 'forward',
1077
999
                include_merges=False))
1078
1000
        self.assertEqual(revisions, revisions2)
1082
1004
        mainline_revs, rev_nos, wt = self.make_tree_with_commits()
1083
1005
        wt.lock_read()
1084
1006
        self.addCleanup(wt.unlock)
1085
 
        revisions = list(log.get_view_revisions(
 
1007
        revisions = list(self._get_view_revisions(
1086
1008
                mainline_revs, rev_nos, wt.branch, 'reverse'))
1087
1009
        self.assertEqual([('3', '3', 0), ('2', '2', 0), ('1', '1', 0), ],
1088
1010
                         revisions)
1089
 
        revisions2 = list(log.get_view_revisions(
 
1011
        revisions2 = list(self._get_view_revisions(
1090
1012
                mainline_revs, rev_nos, wt.branch, 'reverse',
1091
1013
                include_merges=False))
1092
1014
        self.assertEqual(revisions, revisions2)
1096
1018
        mainline_revs, rev_nos, wt = self.make_tree_with_merges()
1097
1019
        wt.lock_read()
1098
1020
        self.addCleanup(wt.unlock)
1099
 
        revisions = list(log.get_view_revisions(
 
1021
        revisions = list(self._get_view_revisions(
1100
1022
                mainline_revs, rev_nos, wt.branch, 'forward'))
1101
1023
        self.assertEqual([('1', '1', 0), ('2', '2', 0), ('3', '3', 0),
1102
1024
                          ('4b', '4', 0), ('4a', '3.1.1', 1)],
1103
1025
                         revisions)
1104
 
        revisions = list(log.get_view_revisions(
 
1026
        revisions = list(self._get_view_revisions(
1105
1027
                mainline_revs, rev_nos, wt.branch, 'forward',
1106
1028
                include_merges=False))
1107
1029
        self.assertEqual([('1', '1', 0), ('2', '2', 0), ('3', '3', 0),
1113
1035
        mainline_revs, rev_nos, wt = self.make_tree_with_merges()
1114
1036
        wt.lock_read()
1115
1037
        self.addCleanup(wt.unlock)
1116
 
        revisions = list(log.get_view_revisions(
 
1038
        revisions = list(self._get_view_revisions(
1117
1039
                mainline_revs, rev_nos, wt.branch, 'reverse'))
1118
1040
        self.assertEqual([('4b', '4', 0), ('4a', '3.1.1', 1),
1119
1041
                          ('3', '3', 0), ('2', '2', 0), ('1', '1', 0)],
1120
1042
                         revisions)
1121
 
        revisions = list(log.get_view_revisions(
 
1043
        revisions = list(self._get_view_revisions(
1122
1044
                mainline_revs, rev_nos, wt.branch, 'reverse',
1123
1045
                include_merges=False))
1124
1046
        self.assertEqual([('4b', '4', 0), ('3', '3', 0), ('2', '2', 0),
1130
1052
        mainline_revs, rev_nos, b = self.make_branch_with_many_merges()
1131
1053
        b.lock_read()
1132
1054
        self.addCleanup(b.unlock)
1133
 
        revisions = list(log.get_view_revisions(
 
1055
        revisions = list(self._get_view_revisions(
1134
1056
                mainline_revs, rev_nos, b, 'forward'))
1135
1057
        expected = [('1', '1', 0), ('2', '2', 0), ('3c', '3', 0),
1136
1058
                    ('3b', '2.2.1', 1), ('3a', '2.1.1', 2), ('4b', '4', 0),
1137
1059
                    ('4a', '2.2.2', 1)]
1138
1060
        self.assertEqual(expected, revisions)
1139
 
        revisions = list(log.get_view_revisions(
 
1061
        revisions = list(self._get_view_revisions(
1140
1062
                mainline_revs, rev_nos, b, 'forward',
1141
1063
                include_merges=False))
1142
1064
        self.assertEqual([('1', '1', 0), ('2', '2', 0), ('3c', '3', 0),
1143
1065
                          ('4b', '4', 0)],
1144
1066
                         revisions)
1145
1067
 
1146
 
 
1147
1068
    def test_file_id_for_range(self):
1148
1069
        mainline_revs, rev_nos, b = self.make_branch_with_many_merges()
1149
1070
        b.lock_read()
1154
1075
            return revspec.in_history(branch)
1155
1076
 
1156
1077
        def view_revs(start_rev, end_rev, file_id, direction):
1157
 
            revs = log.calculate_view_revisions(
 
1078
            revs = self.applyDeprecated(
 
1079
                symbol_versioning.deprecated_in((2, 2, 0)),
 
1080
                log.calculate_view_revisions,
1158
1081
                b,
1159
1082
                start_rev, # start_revision
1160
1083
                end_rev, # end_revision
1166
1089
 
1167
1090
        rev_3a = rev_from_rev_id('3a', b)
1168
1091
        rev_4b = rev_from_rev_id('4b', b)
1169
 
        self.assertEqual([('3c', '3', 0), ('3b', '2.2.1', 1), ('3a', '2.1.1', 2)],
 
1092
        self.assertEqual([('3c', '3', 0), ('3b', '2.2.1', 1),
 
1093
                          ('3a', '2.1.1', 2)],
1170
1094
                          view_revs(rev_3a, rev_4b, 'f-id', 'reverse'))
1171
1095
        # Note: 3c still appears before 3a here because of depth-based sorting
1172
 
        self.assertEqual([('3c', '3', 0), ('3b', '2.2.1', 1), ('3a', '2.1.1', 2)],
 
1096
        self.assertEqual([('3c', '3', 0), ('3b', '2.2.1', 1),
 
1097
                          ('3a', '2.1.1', 2)],
1173
1098
                          view_revs(rev_3a, rev_4b, 'f-id', 'forward'))
1174
1099
 
1175
1100
 
1176
1101
class TestGetRevisionsTouchingFileID(tests.TestCaseWithTransport):
1177
1102
 
 
1103
    def get_view_revisions(self, *args):
 
1104
        return self.applyDeprecated(symbol_versioning.deprecated_in((2, 2, 0)),
 
1105
                                    log.get_view_revisions, *args)
 
1106
 
1178
1107
    def create_tree_with_single_merge(self):
1179
1108
        """Create a branch with a moderate layout.
1180
1109
 
1198
1127
        #       use it. Since 'log' only uses the tree in a readonly
1199
1128
        #       fashion, it seems a shame to regenerate an identical
1200
1129
        #       tree for each test.
 
1130
        # TODO: vila 20100122 One way to address the shame above will be to
 
1131
        #       create a memory tree during test parametrization and give a
 
1132
        #       *copy* of this tree to each test. Copying a memory tree ought
 
1133
        #       to be cheap, at least cheaper than creating them with such
 
1134
        #       complex setups.
1201
1135
        tree = self.make_branch_and_tree('tree')
1202
1136
        tree.lock_write()
1203
1137
        self.addCleanup(tree.unlock)
1278
1212
        mainline = tree.branch.revision_history()
1279
1213
        mainline.insert(0, None)
1280
1214
        revnos = dict((rev, idx+1) for idx, rev in enumerate(mainline))
1281
 
        view_revs_iter = log.get_view_revisions(mainline, revnos, tree.branch,
1282
 
                                                'reverse', True)
 
1215
        view_revs_iter = self.get_view_revisions(
 
1216
            mainline, revnos, tree.branch, 'reverse', True)
1283
1217
        actual_revs = log._filter_revisions_touching_file_id(
1284
 
                            tree.branch,
1285
 
                            file_id,
1286
 
                            list(view_revs_iter))
 
1218
            tree.branch, file_id, list(view_revs_iter))
1287
1219
        self.assertEqual(revisions, [r for r, revno, depth in actual_revs])
1288
1220
 
1289
1221
    def test_file_id_f1(self):
1341
1273
 
1342
1274
class TestLogFormatter(tests.TestCase):
1343
1275
 
 
1276
    def setUp(self):
 
1277
        super(TestLogFormatter, self).setUp()
 
1278
        self.rev = revision.Revision('a-id')
 
1279
        self.lf = log.LogFormatter(None)
 
1280
 
1344
1281
    def test_short_committer(self):
1345
 
        rev = revision.Revision('a-id')
1346
 
        rev.committer = 'John Doe <jdoe@example.com>'
1347
 
        lf = log.LogFormatter(None)
1348
 
        self.assertEqual('John Doe', lf.short_committer(rev))
1349
 
        rev.committer = 'John Smith <jsmith@example.com>'
1350
 
        self.assertEqual('John Smith', lf.short_committer(rev))
1351
 
        rev.committer = 'John Smith'
1352
 
        self.assertEqual('John Smith', lf.short_committer(rev))
1353
 
        rev.committer = 'jsmith@example.com'
1354
 
        self.assertEqual('jsmith@example.com', lf.short_committer(rev))
1355
 
        rev.committer = '<jsmith@example.com>'
1356
 
        self.assertEqual('jsmith@example.com', lf.short_committer(rev))
1357
 
        rev.committer = 'John Smith jsmith@example.com'
1358
 
        self.assertEqual('John Smith', lf.short_committer(rev))
 
1282
        def assertCommitter(expected, committer):
 
1283
            self.rev.committer = committer
 
1284
            self.assertEqual(expected, self.lf.short_committer(self.rev))
 
1285
 
 
1286
        assertCommitter('John Doe', 'John Doe <jdoe@example.com>')
 
1287
        assertCommitter('John Smith', 'John Smith <jsmith@example.com>')
 
1288
        assertCommitter('John Smith', 'John Smith')
 
1289
        assertCommitter('jsmith@example.com', 'jsmith@example.com')
 
1290
        assertCommitter('jsmith@example.com', '<jsmith@example.com>')
 
1291
        assertCommitter('John Smith', 'John Smith jsmith@example.com')
1359
1292
 
1360
1293
    def test_short_author(self):
1361
 
        rev = revision.Revision('a-id')
1362
 
        rev.committer = 'John Doe <jdoe@example.com>'
1363
 
        lf = log.LogFormatter(None)
1364
 
        self.assertEqual('John Doe', lf.short_author(rev))
1365
 
        rev.properties['author'] = 'John Smith <jsmith@example.com>'
1366
 
        self.assertEqual('John Smith', lf.short_author(rev))
1367
 
        rev.properties['author'] = 'John Smith'
1368
 
        self.assertEqual('John Smith', lf.short_author(rev))
1369
 
        rev.properties['author'] = 'jsmith@example.com'
1370
 
        self.assertEqual('jsmith@example.com', lf.short_author(rev))
1371
 
        rev.properties['author'] = '<jsmith@example.com>'
1372
 
        self.assertEqual('jsmith@example.com', lf.short_author(rev))
1373
 
        rev.properties['author'] = 'John Smith jsmith@example.com'
1374
 
        self.assertEqual('John Smith', lf.short_author(rev))
1375
 
        del rev.properties['author']
1376
 
        rev.properties['authors'] = ('John Smith <jsmith@example.com>\n'
1377
 
                'Jane Rey <jrey@example.com>')
1378
 
        self.assertEqual('John Smith', lf.short_author(rev))
 
1294
        def assertAuthor(expected, author):
 
1295
            self.rev.properties['author'] = author
 
1296
            self.assertEqual(expected, self.lf.short_author(self.rev))
 
1297
 
 
1298
        assertAuthor('John Smith', 'John Smith <jsmith@example.com>')
 
1299
        assertAuthor('John Smith', 'John Smith')
 
1300
        assertAuthor('jsmith@example.com', 'jsmith@example.com')
 
1301
        assertAuthor('jsmith@example.com', '<jsmith@example.com>')
 
1302
        assertAuthor('John Smith', 'John Smith jsmith@example.com')
 
1303
 
 
1304
    def test_short_author_from_committer(self):
 
1305
        self.rev.committer = 'John Doe <jdoe@example.com>'
 
1306
        self.assertEqual('John Doe', self.lf.short_author(self.rev))
 
1307
 
 
1308
    def test_short_author_from_authors(self):
 
1309
        self.rev.properties['authors'] = ('John Smith <jsmith@example.com>\n'
 
1310
                                          'Jane Rey <jrey@example.com>')
 
1311
        self.assertEqual('John Smith', self.lf.short_author(self.rev))
1379
1312
 
1380
1313
 
1381
1314
class TestReverseByDepth(tests.TestCase):
1530
1463
 
1531
1464
 
1532
1465
 
1533
 
class TestLogWithBugs(TestCaseForLogFormatter):
 
1466
class TestLogWithBugs(TestCaseForLogFormatter, TestLogMixin):
1534
1467
 
1535
1468
    def setUp(self):
1536
1469
        TestCaseForLogFormatter.setUp(self)
1543
1476
        tree = self.make_branch_and_tree(u'.')
1544
1477
        self.build_tree(['a', 'b'])
1545
1478
        tree.add('a')
1546
 
        tree.commit('simple log message', rev_id='a1',
1547
 
                    timestamp=1132586655.459960938, timezone=-6*3600,
1548
 
                    committer='Joe Foo <joe@foo.com>',
1549
 
                    revprops={'bugs': 'test://bug/id fixed'})
 
1479
        self.wt_commit(tree, 'simple log message', rev_id='a1',
 
1480
                       revprops={'bugs': 'test://bug/id fixed'})
1550
1481
        tree.add('b')
1551
 
        tree.commit('multiline\nlog\nmessage\n', rev_id='a2',
1552
 
                    timestamp=1132586842.411175966, timezone=-6*3600,
1553
 
                    committer='Joe Foo <joe@foo.com>',
1554
 
                    authors=['Joe Bar <joe@bar.com>'],
1555
 
                    revprops={'bugs': 'test://bug/id fixed\n'
1556
 
                                      'test://bug/2 fixed'})
 
1482
        self.wt_commit(tree, 'multiline\nlog\nmessage\n', rev_id='a2',
 
1483
                       authors=['Joe Bar <joe@bar.com>'],
 
1484
                       revprops={'bugs': 'test://bug/id fixed\n'
 
1485
                                 'test://bug/2 fixed'})
1557
1486
        return tree
1558
1487
 
1559
1488
 
1566
1495
author: Joe Bar <joe@bar.com>
1567
1496
committer: Joe Foo <joe@foo.com>
1568
1497
branch nick: work
1569
 
timestamp: Mon 2005-11-21 09:27:22 -0600
 
1498
timestamp: Tue 2005-11-22 00:00:01 +0000
1570
1499
message:
1571
1500
  multiline
1572
1501
  log
1576
1505
fixes bug(s): test://bug/id
1577
1506
committer: Joe Foo <joe@foo.com>
1578
1507
branch nick: work
1579
 
timestamp: Mon 2005-11-21 09:24:15 -0600
 
1508
timestamp: Tue 2005-11-22 00:00:00 +0000
1580
1509
message:
1581
1510
  simple log message
1582
1511
""",
1585
1514
    def test_short_bugs(self):
1586
1515
        tree = self.make_commits_with_bugs()
1587
1516
        self.assertFormatterResult("""\
1588
 
    2 Joe Bar\t2005-11-21
 
1517
    2 Joe Bar\t2005-11-22
1589
1518
      fixes bug(s): test://bug/id test://bug/2
1590
1519
      multiline
1591
1520
      log
1592
1521
      message
1593
1522
 
1594
 
    1 Joe Foo\t2005-11-21
 
1523
    1 Joe Foo\t2005-11-22
1595
1524
      fixes bug(s): test://bug/id
1596
1525
      simple log message
1597
1526
 
1601
1530
    def test_wrong_bugs_property(self):
1602
1531
        tree = self.make_branch_and_tree(u'.')
1603
1532
        self.build_tree(['foo'])
1604
 
        tree.commit('simple log message', rev_id='a1',
1605
 
              timestamp=1132586655.459960938, timezone=-6*3600,
1606
 
              committer='Joe Foo <joe@foo.com>',
1607
 
              revprops={'bugs': 'test://bug/id invalid_value'})
 
1533
        self.wt_commit(tree, 'simple log message', rev_id='a1',
 
1534
                       revprops={'bugs': 'test://bug/id invalid_value'})
1608
1535
        self.assertFormatterResult("""\
1609
 
    1 Joe Foo\t2005-11-21
 
1536
    1 Joe Foo\t2005-11-22
1610
1537
      simple log message
1611
1538
 
1612
1539
""",