/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_log.py

Use a data factory for commit properties and reduce code duplication.

* bzrlib/tests/test_log.py:
(TestLogMixin.wt_commit): Helper acting as a data factory for
commit properties.
(TestCaseForLogFormatter): Use TestLogMixin and wt_commit()
(TestCaseForLogFormatter.assertFormatterResult): Get rid of
normalize_log() use.
(TestCaseForLogFormatter, TestShortLogFormatterWithMergeRevisions,
TestLongLogFormatter, TestLineLogFormatter, TestGetViewRevisions,
TestHistoryChange, TestLogWithBugs): Use wt_commit() and stop
using run_bzr().

* bzrlib/tests/blackbox/test_log.py:
(TestLog): Use test_log.TestLogMixin and get rid of
commit_options().
(TestLogMerges.make_branches_with_merges,
TestLogDiff.make_branch_with_diffs): Use wt_commit().

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
    )
29
29
 
30
30
 
31
 
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):
32
51
 
33
52
    def setUp(self):
34
53
        super(TestCaseForLogFormatter, self).setUp()
42
61
        self.addCleanup(restore)
43
62
 
44
63
    def assertFormatterResult(self, result, branch, formatter_class,
45
 
                              formatter_kwargs=None, show_log_kwargs=None,
46
 
                              normalize=False):
 
64
                              formatter_kwargs=None, show_log_kwargs=None):
47
65
        logfile = self.make_utf8_encoded_stringio()
48
66
        if formatter_kwargs is None:
49
67
            formatter_kwargs = {}
51
69
        if show_log_kwargs is None:
52
70
            show_log_kwargs = {}
53
71
        log.show_log(branch, formatter, **show_log_kwargs)
54
 
        log_content = logfile.getvalue()
55
 
        if normalize:
56
 
            log_content = normalize_log(log_content)
57
 
        self.assertEqualDiff(result, log_content)
 
72
        self.assertEqualDiff(result, logfile.getvalue())
58
73
 
59
74
    def make_standard_commit(self, branch_nick, **kwargs):
60
75
        wt = self.make_branch_and_tree('.')
63
78
        self.build_tree(['a'])
64
79
        wt.add(['a'])
65
80
        wt.branch.nick = branch_nick
66
 
        kwargs = dict(kwargs)
67
 
        kwargs.setdefault('message', 'add a')
68
 
        kwargs.setdefault('timestamp', 1132711707)
69
 
        kwargs.setdefault('timezone', 36000)
70
81
        kwargs.setdefault('committer', 'Lorem Ipsum <test@example.com>')
71
82
        kwargs.setdefault('authors', ['John Doe <jdoe@example.com>'])
72
 
        wt.commit(**kwargs)
 
83
        self.wt_commit(wt, 'add a', **kwargs)
73
84
        return wt
74
85
 
75
86
    def make_commits_with_trailing_newlines(self, wt):
77
88
        b = wt.branch
78
89
        b.nick = 'test'
79
90
        self.build_tree_contents([('a', 'hello moto\n')])
80
 
        wt.commit('simple log message', rev_id='a1',
81
 
                  timestamp=1132586655.459960938, timezone=-6*3600,
82
 
                  committer='Joe Foo <joe@foo.com>')
 
91
        self.wt_commit(wt, 'simple log message', rev_id='a1')
83
92
        self.build_tree_contents([('b', 'goodbye\n')])
84
93
        wt.add('b')
85
 
        wt.commit('multiline\nlog\nmessage\n', rev_id='a2',
86
 
                  timestamp=1132586842.411175966, timezone=-6*3600,
87
 
                  committer='Joe Foo <joe@foo.com>',
88
 
                  authors=['Joe Bar <joe@bar.com>'])
 
94
        self.wt_commit(wt, 'multiline\nlog\nmessage\n', rev_id='a2')
89
95
 
90
96
        self.build_tree_contents([('c', 'just another manic monday\n')])
91
97
        wt.add('c')
92
 
        wt.commit('single line with trailing newline\n', rev_id='a3',
93
 
                  timestamp=1132587176.835228920, timezone=-6*3600,
94
 
                  committer = 'Joe Foo <joe@foo.com>')
 
98
        self.wt_commit(wt, 'single line with trailing newline\n', rev_id='a3')
95
99
        return b
96
100
 
97
101
    def _prepare_tree_with_merges(self, with_tags=False):
99
103
        wt.lock_write()
100
104
        self.addCleanup(wt.unlock)
101
105
        wt.add('')
102
 
        wt.commit('rev-1', rev_id='rev-1',
103
 
                  timestamp=1132586655, timezone=36000,
104
 
                  committer='Joe Foo <joe@foo.com>')
105
 
        wt.commit('rev-merged', rev_id='rev-2a',
106
 
                  timestamp=1132586700, timezone=36000,
107
 
                  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')
108
108
        wt.set_parent_ids(['rev-1', 'rev-2a'])
109
109
        wt.branch.set_last_revision_info(1, 'rev-1')
110
 
        wt.commit('rev-2', rev_id='rev-2b',
111
 
                  timestamp=1132586800, timezone=36000,
112
 
                  committer='Joe Foo <joe@foo.com>')
 
110
        self.wt_commit(wt, 'rev-2', rev_id='rev-2b')
113
111
        if with_tags:
114
112
            branch = wt.branch
115
113
            branch.tags.set_tag('v0.2', 'rev-2b')
116
 
            wt.commit('rev-3', rev_id='rev-3',
117
 
                      timestamp=1132586900, timezone=36000,
118
 
                      committer='Jane Foo <jane@foo.com>')
 
114
            self.wt_commit(wt, 'rev-3', rev_id='rev-3')
119
115
            branch.tags.set_tag('v1.0rc1', 'rev-3')
120
116
            branch.tags.set_tag('v1.0', 'rev-3')
121
117
        return wt
309
305
        wt = self.make_branch_and_tree('.')
310
306
        b = self.make_commits_with_trailing_newlines(wt)
311
307
        self.assertFormatterResult("""\
312
 
    3 Joe Foo\t2005-11-21
 
308
    3 Joe Foo\t2005-11-22
313
309
      single line with trailing newline
314
310
 
315
 
    2 Joe Bar\t2005-11-21
 
311
    2 Joe Foo\t2005-11-22
316
312
      multiline
317
313
      log
318
314
      message
319
315
 
320
 
    1 Joe Foo\t2005-11-21
 
316
    1 Joe Foo\t2005-11-22
321
317
      simple log message
322
318
 
323
319
""",
354
350
        wt.lock_write()
355
351
        self.addCleanup(wt.unlock)
356
352
        wt.add('')
357
 
        wt.commit('rev-1', rev_id='rev-1',
358
 
                  timestamp=1132586655, timezone=36000,
359
 
                  committer='Joe Foo <joe@foo.com>')
360
 
        wt.commit('rev-merged', rev_id='rev-2a',
361
 
                  timestamp=1132586700, timezone=36000,
362
 
                  committer='Joe Foo <joe@foo.com>')
 
353
        self.wt_commit(wt, 'rev-1', rev_id='rev-1')
 
354
        self.wt_commit(wt, 'rev-merged', rev_id='rev-2a')
363
355
        wt.branch.set_last_revision_info(1, 'rev-1')
364
356
        wt.set_parent_ids(['rev-1', 'rev-2a'])
365
 
        wt.commit('rev-2b', rev_id='rev-2b',
366
 
                  timestamp=1132586800, timezone=36000,
367
 
                  committer='Joe Foo <joe@foo.com>')
368
 
        wt.commit('rev-3a', rev_id='rev-3a',
369
 
                  timestamp=1132586800, timezone=36000,
370
 
                  committer='Joe Foo <joe@foo.com>')
 
357
        self.wt_commit(wt, 'rev-2b', rev_id='rev-2b')
 
358
        self.wt_commit(wt, 'rev-3a', rev_id='rev-3a')
371
359
        wt.branch.set_last_revision_info(2, 'rev-2b')
372
360
        wt.set_parent_ids(['rev-2b', 'rev-3a'])
373
 
        wt.commit('rev-3b', rev_id='rev-3b',
374
 
                  timestamp=1132586800, timezone=36000,
375
 
                  committer='Joe Foo <joe@foo.com>')
 
361
        self.wt_commit(wt, 'rev-3b', rev_id='rev-3b')
376
362
        self.assertFormatterResult("""\
377
363
    3 Joe Foo\t2005-11-22 [merge]
378
364
      rev-3b
387
373
    def test_short_log_with_tags(self):
388
374
        wt = self._prepare_tree_with_merges(with_tags=True)
389
375
        self.assertFormatterResult("""\
390
 
    3 Jane Foo\t2005-11-22 {v1.0, v1.0rc1}
 
376
    3 Joe Foo\t2005-11-22 {v1.0, v1.0rc1}
391
377
      rev-3
392
378
 
393
379
    2 Joe Foo\t2005-11-22 {v0.2} [merge]
404
390
        wt.lock_write()
405
391
        self.addCleanup(wt.unlock)
406
392
        wt.add('')
407
 
        wt.commit('rev-1', rev_id='rev-1',
408
 
                  timestamp=1132586655, timezone=36000,
409
 
                  committer='Joe Foo <joe@foo.com>')
410
 
        wt.commit('rev-merged', rev_id='rev-2a',
411
 
                  timestamp=1132586700, timezone=36000,
412
 
                  committer='Joe Foo <joe@foo.com>')
 
393
        self.wt_commit(wt, 'rev-1', rev_id='rev-1')
 
394
        self.wt_commit(wt, 'rev-merged', rev_id='rev-2a')
413
395
        wt.set_parent_ids(['rev-1', 'rev-2a'])
414
396
        wt.branch.set_last_revision_info(1, 'rev-1')
415
 
        wt.commit('rev-2', rev_id='rev-2b',
416
 
                  timestamp=1132586800, timezone=36000,
417
 
                  committer='Joe Foo <joe@foo.com>')
 
397
        self.wt_commit(wt, 'rev-2', rev_id='rev-2b')
418
398
        revspec = revisionspec.RevisionSpec.from_string('1.1.1')
419
399
        rev = revspec.in_history(wt.branch)
420
400
        self.assertFormatterResult("""\
433
413
        wt.lock_write()
434
414
        self.addCleanup(wt.unlock)
435
415
        wt.add('')
436
 
        wt.commit('rev-1', rev_id='rev-1',
437
 
                  timestamp=1132586655, timezone=36000,
438
 
                  committer='Joe Foo <joe@foo.com>')
439
 
        wt.commit('rev-merged', rev_id='rev-2a',
440
 
                  timestamp=1132586700, timezone=36000,
441
 
                  committer='Joe Foo <joe@foo.com>')
 
416
        self.wt_commit(wt, 'rev-1', rev_id='rev-1')
 
417
        self.wt_commit(wt, 'rev-merged', rev_id='rev-2a')
442
418
        wt.set_parent_ids(['rev-1', 'rev-2a'])
443
419
        wt.branch.set_last_revision_info(1, 'rev-1')
444
 
        wt.commit('rev-2', rev_id='rev-2b',
445
 
                  timestamp=1132586800, timezone=36000,
446
 
                  committer='Joe Foo <joe@foo.com>')
 
420
        self.wt_commit(wt, 'rev-2', rev_id='rev-2b')
447
421
        # Note that the 1.1.1 indenting is in fact correct given that
448
422
        # the revision numbers are right justified within 5 characters
449
423
        # for mainline revnos and 9 characters for dotted revnos.
466
440
        wt.lock_write()
467
441
        self.addCleanup(wt.unlock)
468
442
        wt.add('')
469
 
        wt.commit('rev-1', rev_id='rev-1',
470
 
                  timestamp=1132586655, timezone=36000,
471
 
                  committer='Joe Foo <joe@foo.com>')
472
 
        wt.commit('rev-merged', rev_id='rev-2a',
473
 
                  timestamp=1132586700, timezone=36000,
474
 
                  committer='Joe Foo <joe@foo.com>')
 
443
        self.wt_commit(wt, 'rev-1', rev_id='rev-1')
 
444
        self.wt_commit(wt, 'rev-merged', rev_id='rev-2a')
475
445
        wt.set_parent_ids(['rev-1', 'rev-2a'])
476
446
        wt.branch.set_last_revision_info(1, 'rev-1')
477
 
        wt.commit('rev-2', rev_id='rev-2b',
478
 
                  timestamp=1132586800, timezone=36000,
479
 
                  committer='Joe Foo <joe@foo.com>')
 
447
        self.wt_commit(wt, 'rev-2', rev_id='rev-2b')
480
448
        revspec = revisionspec.RevisionSpec.from_string('1.1.1')
481
449
        rev = revspec.in_history(wt.branch)
482
450
        self.assertFormatterResult("""\
502
470
revno: 1
503
471
committer: Lorem Ipsum <test@example.com>
504
472
branch nick: test_verbose_log
505
 
timestamp: Wed 2005-11-23 12:08:27 +1000
 
473
timestamp: Tue 2005-11-22 00:00:00 +0000
506
474
message:
507
475
  add a
508
476
added:
513
481
 
514
482
    def test_merges_are_indented_by_level(self):
515
483
        wt = self.make_branch_and_tree('parent')
516
 
        wt.commit('first post')
517
 
        self.run_bzr('branch parent child')
518
 
        self.run_bzr(['commit', '-m', 'branch 1', '--unchanged', 'child'])
519
 
        self.run_bzr('branch child smallerchild')
520
 
        self.run_bzr(['commit', '-m', 'branch 2', '--unchanged',
521
 
            'smallerchild'])
522
 
        os.chdir('child')
523
 
        self.run_bzr('merge ../smallerchild')
524
 
        self.run_bzr(['commit', '-m', 'merge branch 2'])
525
 
        os.chdir('../parent')
526
 
        self.run_bzr('merge ../child')
527
 
        wt.commit('merge branch 1')
 
484
        self.wt_commit(wt, 'first post')
 
485
        child_wt = wt.bzrdir.sprout('child').open_workingtree()
 
486
        self.wt_commit(child_wt, 'branch 1')
 
487
        smallerchild_wt = wt.bzrdir.sprout('smallerchild').open_workingtree()
 
488
        self.wt_commit(smallerchild_wt, 'branch 2')
 
489
        child_wt.merge_from_branch(smallerchild_wt.branch)
 
490
        self.wt_commit(child_wt, 'merge branch 2')
 
491
        wt.merge_from_branch(child_wt.branch)
 
492
        self.wt_commit(wt, 'merge branch 1')
528
493
        self.assertFormatterResult("""\
529
494
------------------------------------------------------------
530
495
revno: 2 [merge]
531
 
committer: Lorem Ipsum <test@example.com>
 
496
committer: Joe Foo <joe@foo.com>
532
497
branch nick: parent
533
 
timestamp: Just now
 
498
timestamp: Tue 2005-11-22 00:00:04 +0000
534
499
message:
535
500
  merge branch 1
536
501
    ------------------------------------------------------------
537
502
    revno: 1.1.2 [merge]
538
 
    committer: Lorem Ipsum <test@example.com>
 
503
    committer: Joe Foo <joe@foo.com>
539
504
    branch nick: child
540
 
    timestamp: Just now
 
505
    timestamp: Tue 2005-11-22 00:00:03 +0000
541
506
    message:
542
507
      merge branch 2
543
508
        ------------------------------------------------------------
544
509
        revno: 1.2.1
545
 
        committer: Lorem Ipsum <test@example.com>
 
510
        committer: Joe Foo <joe@foo.com>
546
511
        branch nick: smallerchild
547
 
        timestamp: Just now
 
512
        timestamp: Tue 2005-11-22 00:00:02 +0000
548
513
        message:
549
514
          branch 2
550
515
    ------------------------------------------------------------
551
516
    revno: 1.1.1
552
 
    committer: Lorem Ipsum <test@example.com>
 
517
    committer: Joe Foo <joe@foo.com>
553
518
    branch nick: child
554
 
    timestamp: Just now
 
519
    timestamp: Tue 2005-11-22 00:00:01 +0000
555
520
    message:
556
521
      branch 1
557
522
------------------------------------------------------------
558
523
revno: 1
559
 
committer: Lorem Ipsum <test@example.com>
 
524
committer: Joe Foo <joe@foo.com>
560
525
branch nick: parent
561
 
timestamp: Just now
 
526
timestamp: Tue 2005-11-22 00:00:00 +0000
562
527
message:
563
528
  first post
564
529
""",
565
530
            wt.branch, log.LongLogFormatter,
566
531
            formatter_kwargs=dict(levels=0),
567
 
            show_log_kwargs=dict(verbose=True),
568
 
            normalize=True)
 
532
            show_log_kwargs=dict(verbose=True))
569
533
 
570
534
    def test_verbose_merge_revisions_contain_deltas(self):
571
535
        wt = self.make_branch_and_tree('parent')
572
536
        self.build_tree(['parent/f1', 'parent/f2'])
573
537
        wt.add(['f1','f2'])
574
 
        wt.commit('first post')
575
 
        self.run_bzr('branch parent child')
 
538
        self.wt_commit(wt, 'first post')
 
539
        child_wt = wt.bzrdir.sprout('child').open_workingtree()
576
540
        os.unlink('child/f1')
577
 
        file('child/f2', 'wb').write('hello\n')
578
 
        self.run_bzr(['commit', '-m', 'removed f1 and modified f2',
579
 
            'child'])
580
 
        os.chdir('parent')
581
 
        self.run_bzr('merge ../child')
582
 
        wt.commit('merge branch 1')
 
541
        self.build_tree_contents([('child/f2', 'hello\n')])
 
542
        self.wt_commit(child_wt, 'removed f1 and modified f2')
 
543
        wt.merge_from_branch(child_wt.branch)
 
544
        self.wt_commit(wt, 'merge branch 1')
583
545
        self.assertFormatterResult("""\
584
546
------------------------------------------------------------
585
547
revno: 2 [merge]
586
 
committer: Lorem Ipsum <test@example.com>
 
548
committer: Joe Foo <joe@foo.com>
587
549
branch nick: parent
588
 
timestamp: Just now
 
550
timestamp: Tue 2005-11-22 00:00:02 +0000
589
551
message:
590
552
  merge branch 1
591
553
removed:
594
556
  f2
595
557
    ------------------------------------------------------------
596
558
    revno: 1.1.1
597
 
    committer: Lorem Ipsum <test@example.com>
 
559
    committer: Joe Foo <joe@foo.com>
598
560
    branch nick: child
599
 
    timestamp: Just now
 
561
    timestamp: Tue 2005-11-22 00:00:01 +0000
600
562
    message:
601
563
      removed f1 and modified f2
602
564
    removed:
605
567
      f2
606
568
------------------------------------------------------------
607
569
revno: 1
608
 
committer: Lorem Ipsum <test@example.com>
 
570
committer: Joe Foo <joe@foo.com>
609
571
branch nick: parent
610
 
timestamp: Just now
 
572
timestamp: Tue 2005-11-22 00:00:00 +0000
611
573
message:
612
574
  first post
613
575
added:
616
578
""",
617
579
            wt.branch, log.LongLogFormatter,
618
580
            formatter_kwargs=dict(levels=0),
619
 
            show_log_kwargs=dict(verbose=True),
620
 
            normalize=True)
 
581
            show_log_kwargs=dict(verbose=True))
621
582
 
622
583
    def test_trailing_newlines(self):
623
584
        wt = self.make_branch_and_tree('.')
627
588
revno: 3
628
589
committer: Joe Foo <joe@foo.com>
629
590
branch nick: test
630
 
timestamp: Mon 2005-11-21 09:32:56 -0600
 
591
timestamp: Tue 2005-11-22 00:00:02 +0000
631
592
message:
632
593
  single line with trailing newline
633
594
------------------------------------------------------------
634
595
revno: 2
635
 
author: Joe Bar <joe@bar.com>
636
596
committer: Joe Foo <joe@foo.com>
637
597
branch nick: test
638
 
timestamp: Mon 2005-11-21 09:27:22 -0600
 
598
timestamp: Tue 2005-11-22 00:00:01 +0000
639
599
message:
640
600
  multiline
641
601
  log
644
604
revno: 1
645
605
committer: Joe Foo <joe@foo.com>
646
606
branch nick: test
647
 
timestamp: Mon 2005-11-21 09:24:15 -0600
 
607
timestamp: Tue 2005-11-22 00:00:00 +0000
648
608
message:
649
609
  simple log message
650
610
""",
663
623
author: John Doe <jdoe@example.com>, Jane Rey <jrey@example.com>
664
624
committer: Lorem Ipsum <test@example.com>
665
625
branch nick: test_author_log
666
 
timestamp: Wed 2005-11-23 12:08:27 +1000
 
626
timestamp: Tue 2005-11-22 00:00:00 +0000
667
627
message:
668
628
  add a
669
629
""",
688
648
author: John Doe <jdoe@example.com>
689
649
committer: Lorem Ipsum <test@example.com>
690
650
branch nick: test_properties_in_log
691
 
timestamp: Wed 2005-11-23 12:08:27 +1000
 
651
timestamp: Tue 2005-11-22 00:00:00 +0000
692
652
message:
693
653
  add a
694
654
""",
706
666
            'trivial_custom_prop_handler',
707
667
            trivial_custom_prop_handler)
708
668
        self.assertFormatterResult("""\
709
 
    1 John Doe\t2005-11-23
 
669
    1 John Doe\t2005-11-22
710
670
      test_prop: test_value
711
671
      add a
712
672
 
763
723
revno: 1
764
724
committer: Lorem Ipsum <test@example.com>
765
725
branch nick: test_long_verbose_log
766
 
timestamp: Wed 2005-11-23 12:08:27 +1000
 
726
timestamp: Tue 2005-11-22 00:00:00 +0000
767
727
message:
768
728
  add a
769
729
added:
777
737
        wt = self.make_branch_and_tree('parent')
778
738
        self.build_tree(['parent/f1', 'parent/f2'])
779
739
        wt.add(['f1','f2'])
780
 
        wt.commit('first post')
 
740
        self.wt_commit(wt, 'first post')
781
741
        child_wt = wt.bzrdir.sprout('child').open_workingtree()
782
742
        os.unlink('child/f1')
783
743
        self.build_tree_contents([('child/f2', 'hello\n')])
784
 
        child_wt.commit('removed f1 and modified f2')
 
744
        self.wt_commit(child_wt, 'removed f1 and modified f2')
785
745
        wt.merge_from_branch(child_wt.branch)
786
 
        wt.commit('merge branch 1')
 
746
        self.wt_commit(wt, 'merge branch 1')
787
747
        self.assertFormatterResult("""\
788
748
------------------------------------------------------------
789
749
revno: 2 [merge]
790
 
committer: Lorem Ipsum <test@example.com>
 
750
committer: Joe Foo <joe@foo.com>
791
751
branch nick: parent
792
 
timestamp: Just now
 
752
timestamp: Tue 2005-11-22 00:00:02 +0000
793
753
message:
794
754
  merge branch 1
795
755
removed:
798
758
  f2
799
759
------------------------------------------------------------
800
760
revno: 1
801
 
committer: Lorem Ipsum <test@example.com>
 
761
committer: Joe Foo <joe@foo.com>
802
762
branch nick: parent
803
 
timestamp: Just now
 
763
timestamp: Tue 2005-11-22 00:00:00 +0000
804
764
message:
805
765
  first post
806
766
added:
809
769
""",
810
770
            wt.branch, log.LongLogFormatter,
811
771
            formatter_kwargs=dict(levels=1),
812
 
            show_log_kwargs=dict(verbose=True),
813
 
            normalize=True)
 
772
            show_log_kwargs=dict(verbose=True))
814
773
 
815
774
    def test_long_trailing_newlines(self):
816
775
        wt = self.make_branch_and_tree('.')
820
779
revno: 3
821
780
committer: Joe Foo <joe@foo.com>
822
781
branch nick: test
823
 
timestamp: Mon 2005-11-21 09:32:56 -0600
 
782
timestamp: Tue 2005-11-22 00:00:02 +0000
824
783
message:
825
784
  single line with trailing newline
826
785
------------------------------------------------------------
827
786
revno: 2
828
 
author: Joe Bar <joe@bar.com>
829
787
committer: Joe Foo <joe@foo.com>
830
788
branch nick: test
831
 
timestamp: Mon 2005-11-21 09:27:22 -0600
 
789
timestamp: Tue 2005-11-22 00:00:01 +0000
832
790
message:
833
791
  multiline
834
792
  log
837
795
revno: 1
838
796
committer: Joe Foo <joe@foo.com>
839
797
branch nick: test
840
 
timestamp: Mon 2005-11-21 09:24:15 -0600
 
798
timestamp: Tue 2005-11-22 00:00:00 +0000
841
799
message:
842
800
  simple log message
843
801
""",
855
813
author: John Doe <jdoe@example.com>
856
814
committer: Lorem Ipsum <test@example.com>
857
815
branch nick: test_author_log
858
 
timestamp: Wed 2005-11-23 12:08:27 +1000
 
816
timestamp: Tue 2005-11-22 00:00:00 +0000
859
817
message:
860
818
  add a
861
819
""",
880
838
author: John Doe <jdoe@example.com>
881
839
committer: Lorem Ipsum <test@example.com>
882
840
branch nick: test_properties_in_log
883
 
timestamp: Wed 2005-11-23 12:08:27 +1000
 
841
timestamp: Tue 2005-11-22 00:00:00 +0000
884
842
message:
885
843
  add a
886
844
""",
899
857
                committer='Line-Log-Formatter Tester <test@line.log>',
900
858
                authors=[])
901
859
        self.assertFormatterResult("""\
902
 
1: Line-Log-Formatte... 2005-11-23 add a
 
860
1: Line-Log-Formatte... 2005-11-22 add a
903
861
""",
904
862
            wt.branch, log.LineLogFormatter)
905
863
 
907
865
        wt = self.make_branch_and_tree('.')
908
866
        b = self.make_commits_with_trailing_newlines(wt)
909
867
        self.assertFormatterResult("""\
910
 
3: Joe Foo 2005-11-21 single line with trailing newline
911
 
2: Joe Bar 2005-11-21 multiline
912
 
1: Joe Foo 2005-11-21 simple log message
 
868
3: Joe Foo 2005-11-22 single line with trailing newline
 
869
2: Joe Foo 2005-11-22 multiline
 
870
1: Joe Foo 2005-11-22 simple log message
913
871
""",
914
872
            b, log.LineLogFormatter)
915
873
 
926
884
    def test_line_log_with_tags(self):
927
885
        wt = self._prepare_tree_with_merges(with_tags=True)
928
886
        self.assertFormatterResult("""\
929
 
3: Jane Foo 2005-11-22 {v1.0, v1.0rc1} rev-3
 
887
3: Joe Foo 2005-11-22 {v1.0, v1.0rc1} rev-3
930
888
2: Joe Foo 2005-11-22 [merge] {v0.2} rev-2
931
889
1: Joe Foo 2005-11-22 rev-1
932
890
""",
944
902
                committer='Line-Log-Formatter Tester <test@line.log>',
945
903
                authors=[])
946
904
        self.assertFormatterResult("""\
947
 
1: Line-Log-Formatte... 2005-11-23 add a
 
905
1: Line-Log-Formatte... 2005-11-22 add a
948
906
""",
949
907
            wt.branch, log.LineLogFormatter)
950
908
 
953
911
        wt.lock_write()
954
912
        self.addCleanup(wt.unlock)
955
913
        wt.add('')
956
 
        wt.commit('rev-1', rev_id='rev-1',
957
 
                  timestamp=1132586655, timezone=36000,
958
 
                  committer='Joe Foo <joe@foo.com>')
959
 
        wt.commit('rev-merged', rev_id='rev-2a',
960
 
                  timestamp=1132586700, timezone=36000,
961
 
                  committer='Joe Foo <joe@foo.com>')
 
914
        self.wt_commit(wt, 'rev-1', rev_id='rev-1')
 
915
        self.wt_commit(wt, 'rev-merged', rev_id='rev-2a')
962
916
        wt.set_parent_ids(['rev-1', 'rev-2a'])
963
917
        wt.branch.set_last_revision_info(1, 'rev-1')
964
 
        wt.commit('rev-2', rev_id='rev-2b',
965
 
                  timestamp=1132586800, timezone=36000,
966
 
                  committer='Joe Foo <joe@foo.com>')
 
918
        self.wt_commit(wt, 'rev-2', rev_id='rev-2b')
967
919
        revspec = revisionspec.RevisionSpec.from_string('1.1.1')
968
920
        rev = revspec.in_history(wt.branch)
969
921
        self.assertFormatterResult("""\
978
930
        wt.lock_write()
979
931
        self.addCleanup(wt.unlock)
980
932
        wt.add('')
981
 
        wt.commit('rev-1', rev_id='rev-1',
982
 
                  timestamp=1132586655, timezone=36000,
983
 
                  committer='Joe Foo <joe@foo.com>')
984
 
        wt.commit('rev-merged', rev_id='rev-2a',
985
 
                  timestamp=1132586700, timezone=36000,
986
 
                  committer='Joe Foo <joe@foo.com>')
 
933
        self.wt_commit(wt, 'rev-1', rev_id='rev-1')
 
934
        self.wt_commit(wt, 'rev-merged', rev_id='rev-2a')
987
935
        wt.set_parent_ids(['rev-1', 'rev-2a'])
988
936
        wt.branch.set_last_revision_info(1, 'rev-1')
989
 
        wt.commit('rev-2', rev_id='rev-2b',
990
 
                  timestamp=1132586800, timezone=36000,
991
 
                  committer='Joe Foo <joe@foo.com>')
 
937
        self.wt_commit(wt, 'rev-2', rev_id='rev-2b')
992
938
        self.assertFormatterResult("""\
993
939
2: Joe Foo 2005-11-22 [merge] rev-2
994
940
  1.1.1: Joe Foo 2005-11-22 rev-merged
998
944
            formatter_kwargs=dict(levels=0))
999
945
 
1000
946
 
1001
 
class TestGetViewRevisions(tests.TestCaseWithTransport):
 
947
class TestGetViewRevisions(tests.TestCaseWithTransport, TestLogMixin):
1002
948
 
1003
949
    def make_tree_with_commits(self):
1004
950
        """Create a tree with well-known revision ids"""
1005
951
        wt = self.make_branch_and_tree('tree1')
1006
 
        wt.commit('commit one', rev_id='1')
1007
 
        wt.commit('commit two', rev_id='2')
1008
 
        wt.commit('commit three', rev_id='3')
 
952
        self.wt_commit(wt, 'commit one', rev_id='1')
 
953
        self.wt_commit(wt, 'commit two', rev_id='2')
 
954
        self.wt_commit(wt, 'commit three', rev_id='3')
1009
955
        mainline_revs = [None, '1', '2', '3']
1010
956
        rev_nos = {'1': 1, '2': 2, '3': 3}
1011
957
        return mainline_revs, rev_nos, wt
1014
960
        """Create a tree with well-known revision ids and a merge"""
1015
961
        mainline_revs, rev_nos, wt = self.make_tree_with_commits()
1016
962
        tree2 = wt.bzrdir.sprout('tree2').open_workingtree()
1017
 
        tree2.commit('four-a', rev_id='4a')
 
963
        self.wt_commit(tree2, 'four-a', rev_id='4a')
1018
964
        wt.merge_from_branch(tree2.branch)
1019
 
        wt.commit('four-b', rev_id='4b')
 
965
        self.wt_commit(wt, 'four-b', rev_id='4b')
1020
966
        mainline_revs.append('4b')
1021
967
        rev_nos['4b'] = 4
1022
968
        # 4a: 3.1.1
1536
1482
 
1537
1483
 
1538
1484
 
1539
 
class TestLogWithBugs(TestCaseForLogFormatter):
 
1485
class TestLogWithBugs(TestCaseForLogFormatter, TestLogMixin):
1540
1486
 
1541
1487
    def setUp(self):
1542
1488
        TestCaseForLogFormatter.setUp(self)
1549
1495
        tree = self.make_branch_and_tree(u'.')
1550
1496
        self.build_tree(['a', 'b'])
1551
1497
        tree.add('a')
1552
 
        tree.commit('simple log message', rev_id='a1',
1553
 
                    timestamp=1132586655.459960938, timezone=-6*3600,
1554
 
                    committer='Joe Foo <joe@foo.com>',
1555
 
                    revprops={'bugs': 'test://bug/id fixed'})
 
1498
        self.wt_commit(tree, 'simple log message', rev_id='a1',
 
1499
                       revprops={'bugs': 'test://bug/id fixed'})
1556
1500
        tree.add('b')
1557
 
        tree.commit('multiline\nlog\nmessage\n', rev_id='a2',
1558
 
                    timestamp=1132586842.411175966, timezone=-6*3600,
1559
 
                    committer='Joe Foo <joe@foo.com>',
1560
 
                    authors=['Joe Bar <joe@bar.com>'],
1561
 
                    revprops={'bugs': 'test://bug/id fixed\n'
1562
 
                                      'test://bug/2 fixed'})
 
1501
        self.wt_commit(tree, 'multiline\nlog\nmessage\n', rev_id='a2',
 
1502
                       authors=['Joe Bar <joe@bar.com>'],
 
1503
                       revprops={'bugs': 'test://bug/id fixed\n'
 
1504
                                 'test://bug/2 fixed'})
1563
1505
        return tree
1564
1506
 
1565
1507
 
1572
1514
author: Joe Bar <joe@bar.com>
1573
1515
committer: Joe Foo <joe@foo.com>
1574
1516
branch nick: work
1575
 
timestamp: Mon 2005-11-21 09:27:22 -0600
 
1517
timestamp: Tue 2005-11-22 00:00:01 +0000
1576
1518
message:
1577
1519
  multiline
1578
1520
  log
1582
1524
fixes bug(s): test://bug/id
1583
1525
committer: Joe Foo <joe@foo.com>
1584
1526
branch nick: work
1585
 
timestamp: Mon 2005-11-21 09:24:15 -0600
 
1527
timestamp: Tue 2005-11-22 00:00:00 +0000
1586
1528
message:
1587
1529
  simple log message
1588
1530
""",
1591
1533
    def test_short_bugs(self):
1592
1534
        tree = self.make_commits_with_bugs()
1593
1535
        self.assertFormatterResult("""\
1594
 
    2 Joe Bar\t2005-11-21
 
1536
    2 Joe Bar\t2005-11-22
1595
1537
      fixes bug(s): test://bug/id test://bug/2
1596
1538
      multiline
1597
1539
      log
1598
1540
      message
1599
1541
 
1600
 
    1 Joe Foo\t2005-11-21
 
1542
    1 Joe Foo\t2005-11-22
1601
1543
      fixes bug(s): test://bug/id
1602
1544
      simple log message
1603
1545
 
1607
1549
    def test_wrong_bugs_property(self):
1608
1550
        tree = self.make_branch_and_tree(u'.')
1609
1551
        self.build_tree(['foo'])
1610
 
        tree.commit('simple log message', rev_id='a1',
1611
 
              timestamp=1132586655.459960938, timezone=-6*3600,
1612
 
              committer='Joe Foo <joe@foo.com>',
1613
 
              revprops={'bugs': 'test://bug/id invalid_value'})
 
1552
        self.wt_commit(tree, 'simple log message', rev_id='a1',
 
1553
                       revprops={'bugs': 'test://bug/id invalid_value'})
1614
1554
        self.assertFormatterResult("""\
1615
 
    1 Joe Foo\t2005-11-21
 
1555
    1 Joe Foo\t2005-11-22
1616
1556
      simple log message
1617
1557
 
1618
1558
""",