31
class TestCaseForLogFormatter(tests.TestCaseWithTransport):
31
class TestLogMixin(object):
33
def wt_commit(self, wt, message, **kwargs):
34
"""Use some mostly fixed values for commits to simplify tests.
36
Tests can use this function to get some commit attributes. The time
37
stamp is incremented at each commit.
39
if getattr(self, 'timestamp', None) is None:
40
self.timestamp = 1132617600 # Mon 2005-11-22 00:00:00 +0000
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>')
47
return wt.commit(message, **kwargs)
50
class TestCaseForLogFormatter(tests.TestCaseWithTransport, TestLogMixin):
34
53
super(TestCaseForLogFormatter, self).setUp()
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')])
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')
90
96
self.build_tree_contents([('c', 'just another manic monday\n')])
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')
97
101
def _prepare_tree_with_merges(self, with_tags=False):
100
104
self.addCleanup(wt.unlock)
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')
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')
355
351
self.addCleanup(wt.unlock)
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]
405
391
self.addCleanup(wt.unlock)
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("""\
434
414
self.addCleanup(wt.unlock)
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.
467
441
self.addCleanup(wt.unlock)
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("""\
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',
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
------------------------------------------------------------
531
committer: Lorem Ipsum <test@example.com>
496
committer: Joe Foo <joe@foo.com>
532
497
branch nick: parent
498
timestamp: Tue 2005-11-22 00:00:04 +0000
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
505
timestamp: Tue 2005-11-22 00:00:03 +0000
543
508
------------------------------------------------------------
545
committer: Lorem Ipsum <test@example.com>
510
committer: Joe Foo <joe@foo.com>
546
511
branch nick: smallerchild
512
timestamp: Tue 2005-11-22 00:00:02 +0000
550
515
------------------------------------------------------------
552
committer: Lorem Ipsum <test@example.com>
517
committer: Joe Foo <joe@foo.com>
553
518
branch nick: child
519
timestamp: Tue 2005-11-22 00:00:01 +0000
557
522
------------------------------------------------------------
559
committer: Lorem Ipsum <test@example.com>
524
committer: Joe Foo <joe@foo.com>
560
525
branch nick: parent
526
timestamp: Tue 2005-11-22 00:00:00 +0000
565
530
wt.branch, log.LongLogFormatter,
566
531
formatter_kwargs=dict(levels=0),
567
show_log_kwargs=dict(verbose=True),
532
show_log_kwargs=dict(verbose=True))
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',
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
------------------------------------------------------------
586
committer: Lorem Ipsum <test@example.com>
548
committer: Joe Foo <joe@foo.com>
587
549
branch nick: parent
550
timestamp: Tue 2005-11-22 00:00:02 +0000
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
------------------------------------------------------------
790
committer: Lorem Ipsum <test@example.com>
750
committer: Joe Foo <joe@foo.com>
791
751
branch nick: parent
752
timestamp: Tue 2005-11-22 00:00:02 +0000
954
912
self.addCleanup(wt.unlock)
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("""\
979
931
self.addCleanup(wt.unlock)
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))
1001
class TestGetViewRevisions(tests.TestCaseWithTransport):
947
class TestGetViewRevisions(tests.TestCaseWithTransport, TestLogMixin):
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
1549
1495
tree = self.make_branch_and_tree(u'.')
1550
1496
self.build_tree(['a', 'b'])
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'})
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'})
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