79
62
self.build_tree(['a'])
81
64
wt.branch.nick = branch_nick
66
kwargs.setdefault('message', 'add a')
67
kwargs.setdefault('timestamp', 1132711707)
68
kwargs.setdefault('timezone', 36000)
82
69
kwargs.setdefault('committer', 'Lorem Ipsum <test@example.com>')
83
70
kwargs.setdefault('authors', ['John Doe <jdoe@example.com>'])
84
self.wt_commit(wt, 'add a', **kwargs)
87
def make_commits_with_trailing_newlines(self, wt):
88
"""Helper method for LogFormatter tests"""
91
self.build_tree_contents([('a', 'hello moto\n')])
92
self.wt_commit(wt, 'simple log message', rev_id='a1')
93
self.build_tree_contents([('b', 'goodbye\n')])
95
self.wt_commit(wt, 'multiline\nlog\nmessage\n', rev_id='a2')
97
self.build_tree_contents([('c', 'just another manic monday\n')])
99
self.wt_commit(wt, 'single line with trailing newline\n', rev_id='a3')
102
74
def _prepare_tree_with_merges(self, with_tags=False):
103
75
wt = self.make_branch_and_memory_tree('.')
105
77
self.addCleanup(wt.unlock)
107
self.wt_commit(wt, 'rev-1', rev_id='rev-1')
108
self.wt_commit(wt, 'rev-merged', rev_id='rev-2a')
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>')
109
85
wt.set_parent_ids(['rev-1', 'rev-2a'])
110
86
wt.branch.set_last_revision_info(1, 'rev-1')
111
self.wt_commit(wt, 'rev-2', rev_id='rev-2b')
87
wt.commit('rev-2', rev_id='rev-2b',
88
timestamp=1132586800, timezone=36000,
89
committer='Joe Foo <joe@foo.com>')
113
91
branch = wt.branch
114
92
branch.tags.set_tag('v0.2', 'rev-2b')
115
self.wt_commit(wt, 'rev-3', rev_id='rev-3')
93
wt.commit('rev-3', rev_id='rev-3',
94
timestamp=1132586900, timezone=36000,
95
committer='Jane Foo <jane@foo.com>')
116
96
branch.tags.set_tag('v1.0rc1', 'rev-3')
117
97
branch.tags.set_tag('v1.0', 'rev-3')
120
103
class LogCatcher(log.LogFormatter):
121
104
"""Pull log messages into a list rather than displaying them.
281
260
self.checkDelta(logentry.delta, added=['file1', 'file2'])
263
def make_commits_with_trailing_newlines(wt):
264
"""Helper method for LogFormatter tests"""
267
open('a', 'wb').write('hello moto\n')
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')
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>'])
279
open('c', 'wb').write('just another manic monday\n')
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>')
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)
284
304
class TestShortLogFormatter(TestCaseForLogFormatter):
286
306
def test_trailing_newlines(self):
287
307
wt = self.make_branch_and_tree('.')
288
b = self.make_commits_with_trailing_newlines(wt)
308
b = make_commits_with_trailing_newlines(wt)
289
309
self.assertFormatterResult("""\
290
3 Joe Foo\t2005-11-22
310
3 Joe Foo\t2005-11-21
291
311
single line with trailing newline
293
2 Joe Foo\t2005-11-22
313
2 Joe Bar\t2005-11-21
298
1 Joe Foo\t2005-11-22
318
1 Joe Foo\t2005-11-21
299
319
simple log message
328
348
formatter_kwargs=dict(show_advice=True))
330
350
def test_short_log_with_merges_and_range(self):
331
wt = self._prepare_tree_with_merges()
332
self.wt_commit(wt, 'rev-3a', rev_id='rev-3a')
351
wt = self.make_branch_and_memory_tree('.')
353
self.addCleanup(wt.unlock)
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>')
333
369
wt.branch.set_last_revision_info(2, 'rev-2b')
334
370
wt.set_parent_ids(['rev-2b', 'rev-3a'])
335
self.wt_commit(wt, 'rev-3b', rev_id='rev-3b')
371
wt.commit('rev-3b', rev_id='rev-3b',
372
timestamp=1132586800, timezone=36000,
373
committer='Joe Foo <joe@foo.com>')
336
374
self.assertFormatterResult("""\
337
375
3 Joe Foo\t2005-11-22 [merge]
340
378
2 Joe Foo\t2005-11-22 [merge]
344
382
wt.branch, log.ShortLogFormatter,
432
512
def test_merges_are_indented_by_level(self):
433
513
wt = self.make_branch_and_tree('parent')
434
self.wt_commit(wt, 'first post')
435
child_wt = wt.bzrdir.sprout('child').open_workingtree()
436
self.wt_commit(child_wt, 'branch 1')
437
smallerchild_wt = wt.bzrdir.sprout('smallerchild').open_workingtree()
438
self.wt_commit(smallerchild_wt, 'branch 2')
439
child_wt.merge_from_branch(smallerchild_wt.branch)
440
self.wt_commit(child_wt, 'merge branch 2')
441
wt.merge_from_branch(child_wt.branch)
442
self.wt_commit(wt, 'merge branch 1')
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',
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')
443
526
self.assertFormatterResult("""\
444
527
------------------------------------------------------------
446
committer: Joe Foo <joe@foo.com>
529
committer: Lorem Ipsum <test@example.com>
447
530
branch nick: parent
448
timestamp: Tue 2005-11-22 00:00:04 +0000
451
534
------------------------------------------------------------
452
535
revno: 1.1.2 [merge]
453
committer: Joe Foo <joe@foo.com>
536
committer: Lorem Ipsum <test@example.com>
454
537
branch nick: child
455
timestamp: Tue 2005-11-22 00:00:03 +0000
458
541
------------------------------------------------------------
460
committer: Joe Foo <joe@foo.com>
543
committer: Lorem Ipsum <test@example.com>
461
544
branch nick: smallerchild
462
timestamp: Tue 2005-11-22 00:00:02 +0000
465
548
------------------------------------------------------------
467
committer: Joe Foo <joe@foo.com>
550
committer: Lorem Ipsum <test@example.com>
468
551
branch nick: child
469
timestamp: Tue 2005-11-22 00:00:01 +0000
472
555
------------------------------------------------------------
474
committer: Joe Foo <joe@foo.com>
557
committer: Lorem Ipsum <test@example.com>
475
558
branch nick: parent
476
timestamp: Tue 2005-11-22 00:00:00 +0000
480
563
wt.branch, log.LongLogFormatter,
481
564
formatter_kwargs=dict(levels=0),
482
show_log_kwargs=dict(verbose=True))
565
show_log_kwargs=dict(verbose=True),
484
568
def test_verbose_merge_revisions_contain_deltas(self):
485
569
wt = self.make_branch_and_tree('parent')
486
570
self.build_tree(['parent/f1', 'parent/f2'])
487
571
wt.add(['f1','f2'])
488
self.wt_commit(wt, 'first post')
489
child_wt = wt.bzrdir.sprout('child').open_workingtree()
572
wt.commit('first post')
573
self.run_bzr('branch parent child')
490
574
os.unlink('child/f1')
491
self.build_tree_contents([('child/f2', 'hello\n')])
492
self.wt_commit(child_wt, 'removed f1 and modified f2')
493
wt.merge_from_branch(child_wt.branch)
494
self.wt_commit(wt, 'merge branch 1')
575
file('child/f2', 'wb').write('hello\n')
576
self.run_bzr(['commit', '-m', 'removed f1 and modified f2',
579
self.run_bzr('merge ../child')
580
wt.commit('merge branch 1')
495
581
self.assertFormatterResult("""\
496
582
------------------------------------------------------------
498
committer: Joe Foo <joe@foo.com>
584
committer: Lorem Ipsum <test@example.com>
499
585
branch nick: parent
500
timestamp: Tue 2005-11-22 00:00:02 +0000
852
942
committer='Line-Log-Formatter Tester <test@line.log>',
854
944
self.assertFormatterResult("""\
855
1: Line-Log-Formatte... 2005-11-22 add a
945
1: Line-Log-Formatte... 2005-11-23 add a
857
947
wt.branch, log.LineLogFormatter)
859
949
def test_line_merge_revs_log_single_merge_revision(self):
860
wt = self._prepare_tree_with_merges()
950
wt = self.make_branch_and_memory_tree('.')
952
self.addCleanup(wt.unlock)
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>')
861
965
revspec = revisionspec.RevisionSpec.from_string('1.1.1')
862
966
rev = revspec.in_history(wt.branch)
863
967
self.assertFormatterResult("""\
878
996
formatter_kwargs=dict(levels=0))
881
class TestGnuChangelogFormatter(TestCaseForLogFormatter):
883
def test_gnu_changelog(self):
884
wt = self.make_standard_commit('nicky', authors=[])
885
self.assertFormatterResult('''\
886
2005-11-22 Lorem Ipsum <test@example.com>
891
wt.branch, log.GnuChangelogLogFormatter)
893
def test_with_authors(self):
894
wt = self.make_standard_commit('nicky',
895
authors=['Fooa Fooz <foo@example.com>',
896
'Bari Baro <bar@example.com>'])
897
self.assertFormatterResult('''\
898
2005-11-22 Fooa Fooz <foo@example.com>
903
wt.branch, log.GnuChangelogLogFormatter)
905
def test_verbose(self):
906
wt = self.make_standard_commit('nicky')
907
self.assertFormatterResult('''\
908
2005-11-22 John Doe <jdoe@example.com>
915
wt.branch, log.GnuChangelogLogFormatter,
916
show_log_kwargs=dict(verbose=True))
918
class TestGetViewRevisions(tests.TestCaseWithTransport, TestLogMixin):
920
def _get_view_revisions(self, *args, **kwargs):
921
return self.applyDeprecated(symbol_versioning.deprecated_in((2, 2, 0)),
922
log.get_view_revisions, *args, **kwargs)
999
class TestGetViewRevisions(tests.TestCaseWithTransport):
924
1001
def make_tree_with_commits(self):
925
1002
"""Create a tree with well-known revision ids"""
926
1003
wt = self.make_branch_and_tree('tree1')
927
self.wt_commit(wt, 'commit one', rev_id='1')
928
self.wt_commit(wt, 'commit two', rev_id='2')
929
self.wt_commit(wt, 'commit three', rev_id='3')
1004
wt.commit('commit one', rev_id='1')
1005
wt.commit('commit two', rev_id='2')
1006
wt.commit('commit three', rev_id='3')
930
1007
mainline_revs = [None, '1', '2', '3']
931
1008
rev_nos = {'1': 1, '2': 2, '3': 3}
932
1009
return mainline_revs, rev_nos, wt
1053
1130
mainline_revs, rev_nos, b = self.make_branch_with_many_merges()
1055
1132
self.addCleanup(b.unlock)
1056
revisions = list(self._get_view_revisions(
1133
revisions = list(log.get_view_revisions(
1057
1134
mainline_revs, rev_nos, b, 'forward'))
1058
1135
expected = [('1', '1', 0), ('2', '2', 0), ('3c', '3', 0),
1059
1136
('3b', '2.2.1', 1), ('3a', '2.1.1', 2), ('4b', '4', 0),
1060
1137
('4a', '2.2.2', 1)]
1061
1138
self.assertEqual(expected, revisions)
1062
revisions = list(self._get_view_revisions(
1139
revisions = list(log.get_view_revisions(
1063
1140
mainline_revs, rev_nos, b, 'forward',
1064
1141
include_merges=False))
1065
1142
self.assertEqual([('1', '1', 0), ('2', '2', 0), ('3c', '3', 0),
1066
1143
('4b', '4', 0)],
1069
1147
def test_file_id_for_range(self):
1070
1148
mainline_revs, rev_nos, b = self.make_branch_with_many_merges()
1091
1167
rev_3a = rev_from_rev_id('3a', b)
1092
1168
rev_4b = rev_from_rev_id('4b', b)
1093
self.assertEqual([('3c', '3', 0), ('3b', '2.2.1', 1),
1094
('3a', '2.1.1', 2)],
1169
self.assertEqual([('3c', '3', 0), ('3b', '2.2.1', 1), ('3a', '2.1.1', 2)],
1095
1170
view_revs(rev_3a, rev_4b, 'f-id', 'reverse'))
1096
1171
# Note: 3c still appears before 3a here because of depth-based sorting
1097
self.assertEqual([('3c', '3', 0), ('3b', '2.2.1', 1),
1098
('3a', '2.1.1', 2)],
1172
self.assertEqual([('3c', '3', 0), ('3b', '2.2.1', 1), ('3a', '2.1.1', 2)],
1099
1173
view_revs(rev_3a, rev_4b, 'f-id', 'forward'))
1102
1176
class TestGetRevisionsTouchingFileID(tests.TestCaseWithTransport):
1104
def get_view_revisions(self, *args):
1105
return self.applyDeprecated(symbol_versioning.deprecated_in((2, 2, 0)),
1106
log.get_view_revisions, *args)
1108
1178
def create_tree_with_single_merge(self):
1109
1179
"""Create a branch with a moderate layout.
1275
1342
class TestLogFormatter(tests.TestCase):
1278
super(TestLogFormatter, self).setUp()
1279
self.rev = revision.Revision('a-id')
1280
self.lf = log.LogFormatter(None)
1282
1344
def test_short_committer(self):
1283
def assertCommitter(expected, committer):
1284
self.rev.committer = committer
1285
self.assertEqual(expected, self.lf.short_committer(self.rev))
1287
assertCommitter('John Doe', 'John Doe <jdoe@example.com>')
1288
assertCommitter('John Smith', 'John Smith <jsmith@example.com>')
1289
assertCommitter('John Smith', 'John Smith')
1290
assertCommitter('jsmith@example.com', 'jsmith@example.com')
1291
assertCommitter('jsmith@example.com', '<jsmith@example.com>')
1292
assertCommitter('John Smith', 'John Smith jsmith@example.com')
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))
1294
1360
def test_short_author(self):
1295
def assertAuthor(expected, author):
1296
self.rev.properties['author'] = author
1297
self.assertEqual(expected, self.lf.short_author(self.rev))
1299
assertAuthor('John Smith', 'John Smith <jsmith@example.com>')
1300
assertAuthor('John Smith', 'John Smith')
1301
assertAuthor('jsmith@example.com', 'jsmith@example.com')
1302
assertAuthor('jsmith@example.com', '<jsmith@example.com>')
1303
assertAuthor('John Smith', 'John Smith jsmith@example.com')
1305
def test_short_author_from_committer(self):
1306
self.rev.committer = 'John Doe <jdoe@example.com>'
1307
self.assertEqual('John Doe', self.lf.short_author(self.rev))
1309
def test_short_author_from_authors(self):
1310
self.rev.properties['authors'] = ('John Smith <jsmith@example.com>\n'
1311
'Jane Rey <jrey@example.com>')
1312
self.assertEqual('John Smith', self.lf.short_author(self.rev))
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))
1315
1381
class TestReverseByDepth(tests.TestCase):
1543
1615
def test_bugs_handler_present(self):
1544
1616
self.properties_handler_registry.get('bugs_properties_handler')
1547
class TestLogForAuthors(TestCaseForLogFormatter):
1550
TestCaseForLogFormatter.setUp(self)
1551
self.wt = self.make_standard_commit('nicky',
1552
authors=['John Doe <jdoe@example.com>',
1553
'Jane Rey <jrey@example.com>'])
1555
def assertFormatterResult(self, formatter, who, result):
1556
formatter_kwargs = dict()
1558
author_list_handler = log.author_list_registry.get(who)
1559
formatter_kwargs['author_list_handler'] = author_list_handler
1560
TestCaseForLogFormatter.assertFormatterResult(self, result,
1561
self.wt.branch, formatter, formatter_kwargs=formatter_kwargs)
1563
def test_line_default(self):
1564
self.assertFormatterResult(log.LineLogFormatter, None, """\
1565
1: John Doe 2005-11-22 add a
1568
def test_line_committer(self):
1569
self.assertFormatterResult(log.LineLogFormatter, 'committer', """\
1570
1: Lorem Ipsum 2005-11-22 add a
1573
def test_line_first(self):
1574
self.assertFormatterResult(log.LineLogFormatter, 'first', """\
1575
1: John Doe 2005-11-22 add a
1578
def test_line_all(self):
1579
self.assertFormatterResult(log.LineLogFormatter, 'all', """\
1580
1: John Doe, Jane Rey 2005-11-22 add a
1584
def test_short_default(self):
1585
self.assertFormatterResult(log.ShortLogFormatter, None, """\
1586
1 John Doe\t2005-11-22
1591
def test_short_committer(self):
1592
self.assertFormatterResult(log.ShortLogFormatter, 'committer', """\
1593
1 Lorem Ipsum\t2005-11-22
1598
def test_short_first(self):
1599
self.assertFormatterResult(log.ShortLogFormatter, 'first', """\
1600
1 John Doe\t2005-11-22
1605
def test_short_all(self):
1606
self.assertFormatterResult(log.ShortLogFormatter, 'all', """\
1607
1 John Doe, Jane Rey\t2005-11-22
1612
def test_long_default(self):
1613
self.assertFormatterResult(log.LongLogFormatter, None, """\
1614
------------------------------------------------------------
1616
author: John Doe <jdoe@example.com>, Jane Rey <jrey@example.com>
1617
committer: Lorem Ipsum <test@example.com>
1619
timestamp: Tue 2005-11-22 00:00:00 +0000
1624
def test_long_committer(self):
1625
self.assertFormatterResult(log.LongLogFormatter, 'committer', """\
1626
------------------------------------------------------------
1628
committer: Lorem Ipsum <test@example.com>
1630
timestamp: Tue 2005-11-22 00:00:00 +0000
1635
def test_long_first(self):
1636
self.assertFormatterResult(log.LongLogFormatter, 'first', """\
1637
------------------------------------------------------------
1639
author: John Doe <jdoe@example.com>
1640
committer: Lorem Ipsum <test@example.com>
1642
timestamp: Tue 2005-11-22 00:00:00 +0000
1647
def test_long_all(self):
1648
self.assertFormatterResult(log.LongLogFormatter, 'all', """\
1649
------------------------------------------------------------
1651
author: John Doe <jdoe@example.com>, Jane Rey <jrey@example.com>
1652
committer: Lorem Ipsum <test@example.com>
1654
timestamp: Tue 2005-11-22 00:00:00 +0000
1659
def test_gnu_changelog_default(self):
1660
self.assertFormatterResult(log.GnuChangelogLogFormatter, None, """\
1661
2005-11-22 John Doe <jdoe@example.com>
1667
def test_gnu_changelog_committer(self):
1668
self.assertFormatterResult(log.GnuChangelogLogFormatter, 'committer', """\
1669
2005-11-22 Lorem Ipsum <test@example.com>
1675
def test_gnu_changelog_first(self):
1676
self.assertFormatterResult(log.GnuChangelogLogFormatter, 'first', """\
1677
2005-11-22 John Doe <jdoe@example.com>
1683
def test_gnu_changelog_all(self):
1684
self.assertFormatterResult(log.GnuChangelogLogFormatter, 'all', """\
1685
2005-11-22 John Doe <jdoe@example.com>, Jane Rey <jrey@example.com>
1691
class TestLogExcludeAncestry(tests.TestCaseWithTransport):
1693
def make_branch_with_alternate_ancestries(self, relpath='.'):
1694
# See test_merge_sorted_exclude_ancestry below for the difference with
1695
# bt.per_branch.test_iter_merge_sorted_revision.
1696
# TestIterMergeSortedRevisionsBushyGraph.
1697
# make_branch_with_alternate_ancestries
1698
# and test_merge_sorted_exclude_ancestry
1699
# See the FIXME in assertLogRevnos too.
1700
builder = branchbuilder.BranchBuilder(self.get_transport(relpath))
1712
builder.start_series()
1713
builder.build_snapshot('1', None, [
1714
('add', ('', 'TREE_ROOT', 'directory', '')),])
1715
builder.build_snapshot('1.1.1', ['1'], [])
1716
builder.build_snapshot('2', ['1'], [])
1717
builder.build_snapshot('1.2.1', ['1.1.1'], [])
1718
builder.build_snapshot('1.1.2', ['1.1.1', '1.2.1'], [])
1719
builder.build_snapshot('3', ['2', '1.1.2'], [])
1720
builder.finish_series()
1721
br = builder.get_branch()
1723
self.addCleanup(br.unlock)
1726
def assertLogRevnos(self, expected_revnos, b, start, end,
1727
exclude_common_ancestry, generate_merge_revisions=True):
1728
# FIXME: the layering in log makes it hard to test intermediate levels,
1729
# I wish adding filters with their parameters were easier...
1731
iter_revs = log._calc_view_revisions(
1732
b, start, end, direction='reverse',
1733
generate_merge_revisions=generate_merge_revisions,
1734
exclude_common_ancestry=exclude_common_ancestry)
1735
self.assertEqual(expected_revnos,
1736
[revid for revid, revno, depth in iter_revs])
1738
def test_merge_sorted_exclude_ancestry(self):
1739
b = self.make_branch_with_alternate_ancestries()
1740
self.assertLogRevnos(['3', '1.1.2', '1.2.1', '1.1.1', '2', '1'],
1741
b, '1', '3', exclude_common_ancestry=False)
1742
# '2' is part of the '3' ancestry but not part of '1.1.1' ancestry so
1743
# it should be mentioned even if merge_sort order will make it appear
1745
self.assertLogRevnos(['3', '1.1.2', '1.2.1', '2'],
1746
b, '1.1.1', '3', exclude_common_ancestry=True)
1748
def test_merge_sorted_simple_revnos_exclude_ancestry(self):
1749
b = self.make_branch_with_alternate_ancestries()
1750
self.assertLogRevnos(['3', '2'],
1751
b, '1', '3', exclude_common_ancestry=True,
1752
generate_merge_revisions=False)
1753
self.assertLogRevnos(['3', '1.1.2', '1.2.1', '1.1.1', '2'],
1754
b, '1', '3', exclude_common_ancestry=True,
1755
generate_merge_revisions=True)