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)
924
def make_tree_with_commits(self):
925
"""Create a tree with well-known revision ids"""
926
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')
930
mainline_revs = [None, '1', '2', '3']
931
rev_nos = {'1': 1, '2': 2, '3': 3}
932
return mainline_revs, rev_nos, wt
934
def make_tree_with_merges(self):
935
"""Create a tree with well-known revision ids and a merge"""
936
mainline_revs, rev_nos, wt = self.make_tree_with_commits()
937
tree2 = wt.bzrdir.sprout('tree2').open_workingtree()
938
self.wt_commit(tree2, 'four-a', rev_id='4a')
939
wt.merge_from_branch(tree2.branch)
940
self.wt_commit(wt, 'four-b', rev_id='4b')
941
mainline_revs.append('4b')
944
return mainline_revs, rev_nos, wt
946
def make_branch_with_many_merges(self):
947
"""Create a tree with well-known revision ids"""
948
builder = self.make_branch_builder('tree1')
949
builder.start_series()
950
builder.build_snapshot('1', None, [
951
('add', ('', 'TREE_ROOT', 'directory', '')),
952
('add', ('f', 'f-id', 'file', '1\n'))])
953
builder.build_snapshot('2', ['1'], [])
954
builder.build_snapshot('3a', ['2'], [
955
('modify', ('f-id', '1\n2\n3a\n'))])
956
builder.build_snapshot('3b', ['2', '3a'], [
957
('modify', ('f-id', '1\n2\n3a\n'))])
958
builder.build_snapshot('3c', ['2', '3b'], [
959
('modify', ('f-id', '1\n2\n3a\n'))])
960
builder.build_snapshot('4a', ['3b'], [])
961
builder.build_snapshot('4b', ['3c', '4a'], [])
962
builder.finish_series()
976
mainline_revs = [None, '1', '2', '3c', '4b']
977
rev_nos = {'1':1, '2':2, '3c': 3, '4b':4}
978
full_rev_nos_for_reference = {
981
'3a': '2.1.1', #first commit tree 3
982
'3b': '2.2.1', # first commit tree 2
983
'3c': '3', #merges 3b to main
984
'4a': '2.2.2', # second commit tree 2
985
'4b': '4', # merges 4a to main
987
return mainline_revs, rev_nos, builder.get_branch()
989
def test_get_view_revisions_forward(self):
990
"""Test the get_view_revisions method"""
991
mainline_revs, rev_nos, wt = self.make_tree_with_commits()
993
self.addCleanup(wt.unlock)
994
revisions = list(self._get_view_revisions(
995
mainline_revs, rev_nos, wt.branch, 'forward'))
996
self.assertEqual([('1', '1', 0), ('2', '2', 0), ('3', '3', 0)],
998
revisions2 = list(self._get_view_revisions(
999
mainline_revs, rev_nos, wt.branch, 'forward',
1000
include_merges=False))
1001
self.assertEqual(revisions, revisions2)
1003
def test_get_view_revisions_reverse(self):
1004
"""Test the get_view_revisions with reverse"""
1005
mainline_revs, rev_nos, wt = self.make_tree_with_commits()
1007
self.addCleanup(wt.unlock)
1008
revisions = list(self._get_view_revisions(
1009
mainline_revs, rev_nos, wt.branch, 'reverse'))
1010
self.assertEqual([('3', '3', 0), ('2', '2', 0), ('1', '1', 0), ],
1012
revisions2 = list(self._get_view_revisions(
1013
mainline_revs, rev_nos, wt.branch, 'reverse',
1014
include_merges=False))
1015
self.assertEqual(revisions, revisions2)
1017
def test_get_view_revisions_merge(self):
1018
"""Test get_view_revisions when there are merges"""
1019
mainline_revs, rev_nos, wt = self.make_tree_with_merges()
1021
self.addCleanup(wt.unlock)
1022
revisions = list(self._get_view_revisions(
1023
mainline_revs, rev_nos, wt.branch, 'forward'))
1024
self.assertEqual([('1', '1', 0), ('2', '2', 0), ('3', '3', 0),
1025
('4b', '4', 0), ('4a', '3.1.1', 1)],
1027
revisions = list(self._get_view_revisions(
1028
mainline_revs, rev_nos, wt.branch, 'forward',
1029
include_merges=False))
1030
self.assertEqual([('1', '1', 0), ('2', '2', 0), ('3', '3', 0),
1034
def test_get_view_revisions_merge_reverse(self):
1035
"""Test get_view_revisions in reverse when there are merges"""
1036
mainline_revs, rev_nos, wt = self.make_tree_with_merges()
1038
self.addCleanup(wt.unlock)
1039
revisions = list(self._get_view_revisions(
1040
mainline_revs, rev_nos, wt.branch, 'reverse'))
1041
self.assertEqual([('4b', '4', 0), ('4a', '3.1.1', 1),
1042
('3', '3', 0), ('2', '2', 0), ('1', '1', 0)],
1044
revisions = list(self._get_view_revisions(
1045
mainline_revs, rev_nos, wt.branch, 'reverse',
1046
include_merges=False))
1047
self.assertEqual([('4b', '4', 0), ('3', '3', 0), ('2', '2', 0),
1051
def test_get_view_revisions_merge2(self):
1052
"""Test get_view_revisions when there are merges"""
1053
mainline_revs, rev_nos, b = self.make_branch_with_many_merges()
1055
self.addCleanup(b.unlock)
1056
revisions = list(self._get_view_revisions(
1057
mainline_revs, rev_nos, b, 'forward'))
1058
expected = [('1', '1', 0), ('2', '2', 0), ('3c', '3', 0),
1059
('3b', '2.2.1', 1), ('3a', '2.1.1', 2), ('4b', '4', 0),
1061
self.assertEqual(expected, revisions)
1062
revisions = list(self._get_view_revisions(
1063
mainline_revs, rev_nos, b, 'forward',
1064
include_merges=False))
1065
self.assertEqual([('1', '1', 0), ('2', '2', 0), ('3c', '3', 0),
1069
def test_file_id_for_range(self):
1070
mainline_revs, rev_nos, b = self.make_branch_with_many_merges()
1072
self.addCleanup(b.unlock)
1074
def rev_from_rev_id(revid, branch):
1075
revspec = revisionspec.RevisionSpec.from_string('revid:%s' % revid)
1076
return revspec.in_history(branch)
1078
def view_revs(start_rev, end_rev, file_id, direction):
1079
revs = self.applyDeprecated(
1080
symbol_versioning.deprecated_in((2, 2, 0)),
1081
log.calculate_view_revisions,
1083
start_rev, # start_revision
1084
end_rev, # end_revision
1085
direction, # direction
1086
file_id, # specific_fileid
1087
True, # generate_merge_revisions
1091
rev_3a = rev_from_rev_id('3a', b)
1092
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)],
1095
view_revs(rev_3a, rev_4b, 'f-id', 'reverse'))
1096
# 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)],
1099
view_revs(rev_3a, rev_4b, 'f-id', 'forward'))
1102
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
def create_tree_with_single_merge(self):
1109
"""Create a branch with a moderate layout.
1111
The revision graph looks like:
1119
In this graph, A introduced files f1 and f2 and f3.
1120
B modifies f1 and f3, and C modifies f2 and f3.
1121
D merges the changes from B and C and resolves the conflict for f3.
1123
# TODO: jam 20070218 This seems like it could really be done
1124
# with make_branch_and_memory_tree() if we could just
1125
# create the content of those files.
1126
# TODO: jam 20070218 Another alternative is that we would really
1127
# like to only create this tree 1 time for all tests that
1128
# use it. Since 'log' only uses the tree in a readonly
1129
# fashion, it seems a shame to regenerate an identical
1130
# tree for each test.
1131
# TODO: vila 20100122 One way to address the shame above will be to
1132
# create a memory tree during test parametrization and give a
1133
# *copy* of this tree to each test. Copying a memory tree ought
1134
# to be cheap, at least cheaper than creating them with such
1136
tree = self.make_branch_and_tree('tree')
1138
self.addCleanup(tree.unlock)
1140
self.build_tree_contents([('tree/f1', 'A\n'),
1144
tree.add(['f1', 'f2', 'f3'], ['f1-id', 'f2-id', 'f3-id'])
1145
tree.commit('A', rev_id='A')
1147
self.build_tree_contents([('tree/f2', 'A\nC\n'),
1148
('tree/f3', 'A\nC\n'),
1150
tree.commit('C', rev_id='C')
1151
# Revert back to A to build the other history.
1152
tree.set_last_revision('A')
1153
tree.branch.set_last_revision_info(1, 'A')
1154
self.build_tree_contents([('tree/f1', 'A\nB\n'),
1156
('tree/f3', 'A\nB\n'),
1158
tree.commit('B', rev_id='B')
1159
tree.set_parent_ids(['B', 'C'])
1160
self.build_tree_contents([('tree/f1', 'A\nB\n'),
1161
('tree/f2', 'A\nC\n'),
1162
('tree/f3', 'A\nB\nC\n'),
1164
tree.commit('D', rev_id='D')
1166
# Switch to a read lock for this tree.
1167
# We still have an addCleanup(tree.unlock) pending
1172
def check_delta(self, delta, **kw):
1173
"""Check the filenames touched by a delta are as expected.
1175
Caller only have to pass in the list of files for each part, all
1176
unspecified parts are considered empty (and checked as such).
1178
for n in 'added', 'removed', 'renamed', 'modified', 'unchanged':
1179
# By default we expect an empty list
1180
expected = kw.get(n, [])
1181
# strip out only the path components
1182
got = [x[0] for x in getattr(delta, n)]
1183
self.assertEqual(expected, got)
1185
def test_tree_with_single_merge(self):
1186
"""Make sure the tree layout is correct."""
1187
tree = self.create_tree_with_single_merge()
1188
rev_A_tree = tree.branch.repository.revision_tree('A')
1189
rev_B_tree = tree.branch.repository.revision_tree('B')
1190
rev_C_tree = tree.branch.repository.revision_tree('C')
1191
rev_D_tree = tree.branch.repository.revision_tree('D')
1193
self.check_delta(rev_B_tree.changes_from(rev_A_tree),
1194
modified=['f1', 'f3'])
1196
self.check_delta(rev_C_tree.changes_from(rev_A_tree),
1197
modified=['f2', 'f3'])
1199
self.check_delta(rev_D_tree.changes_from(rev_B_tree),
1200
modified=['f2', 'f3'])
1202
self.check_delta(rev_D_tree.changes_from(rev_C_tree),
1203
modified=['f1', 'f3'])
1205
def assertAllRevisionsForFileID(self, tree, file_id, revisions):
1206
"""Ensure _filter_revisions_touching_file_id returns the right values.
1208
Get the return value from _filter_revisions_touching_file_id and make
1209
sure they are correct.
1211
# The api for _filter_revisions_touching_file_id is a little crazy.
1212
# So we do the setup here.
1213
mainline = tree.branch.revision_history()
1214
mainline.insert(0, None)
1215
revnos = dict((rev, idx+1) for idx, rev in enumerate(mainline))
1216
view_revs_iter = self.get_view_revisions(
1217
mainline, revnos, tree.branch, 'reverse', True)
1218
actual_revs = log._filter_revisions_touching_file_id(
1219
tree.branch, file_id, list(view_revs_iter))
1220
self.assertEqual(revisions, [r for r, revno, depth in actual_revs])
1222
def test_file_id_f1(self):
1223
tree = self.create_tree_with_single_merge()
1224
# f1 should be marked as modified by revisions A and B
1225
self.assertAllRevisionsForFileID(tree, 'f1-id', ['B', 'A'])
1227
def test_file_id_f2(self):
1228
tree = self.create_tree_with_single_merge()
1229
# f2 should be marked as modified by revisions A, C, and D
1230
# because D merged the changes from C.
1231
self.assertAllRevisionsForFileID(tree, 'f2-id', ['D', 'C', 'A'])
1233
def test_file_id_f3(self):
1234
tree = self.create_tree_with_single_merge()
1235
# f3 should be marked as modified by revisions A, B, C, and D
1236
self.assertAllRevisionsForFileID(tree, 'f3-id', ['D', 'C', 'B', 'A'])
1238
def test_file_id_with_ghosts(self):
1239
# This is testing bug #209948, where having a ghost would cause
1240
# _filter_revisions_touching_file_id() to fail.
1241
tree = self.create_tree_with_single_merge()
1242
# We need to add a revision, so switch back to a write-locked tree
1243
# (still a single addCleanup(tree.unlock) pending).
1246
first_parent = tree.last_revision()
1247
tree.set_parent_ids([first_parent, 'ghost-revision-id'])
1248
self.build_tree_contents([('tree/f1', 'A\nB\nXX\n')])
1249
tree.commit('commit with a ghost', rev_id='XX')
1250
self.assertAllRevisionsForFileID(tree, 'f1-id', ['XX', 'B', 'A'])
1251
self.assertAllRevisionsForFileID(tree, 'f2-id', ['D', 'C', 'A'])
1253
def test_unknown_file_id(self):
1254
tree = self.create_tree_with_single_merge()
1255
self.assertAllRevisionsForFileID(tree, 'unknown', [])
1257
def test_empty_branch_unknown_file_id(self):
1258
tree = self.make_branch_and_tree('tree')
1259
self.assertAllRevisionsForFileID(tree, 'unknown', [])
1051
wt.branch, log.GnuChangelogLogFormatter,
1052
show_log_kwargs=dict(verbose=True))
1262
1055
class TestShowChangedRevisions(tests.TestCaseWithTransport):
1372
1165
tree = self.make_branch_and_tree('tree')
1373
1166
tree.lock_write()
1374
1167
self.addCleanup(tree.unlock)
1375
tree.commit('1a', rev_id='1a')
1376
tree.commit('2a', rev_id='2a')
1377
tree.commit('3a', rev_id='3a')
1168
tree.commit('1a', rev_id=b'1a')
1169
tree.commit('2a', rev_id=b'2a')
1170
tree.commit('3a', rev_id=b'3a')
1380
1173
def setup_ab_tree(self):
1381
1174
tree = self.setup_a_tree()
1382
tree.set_last_revision('1a')
1383
tree.branch.set_last_revision_info(1, '1a')
1384
tree.commit('2b', rev_id='2b')
1385
tree.commit('3b', rev_id='3b')
1175
tree.set_last_revision(b'1a')
1176
tree.branch.set_last_revision_info(1, b'1a')
1177
tree.commit('2b', rev_id=b'2b')
1178
tree.commit('3b', rev_id=b'3b')
1388
1181
def setup_ac_tree(self):
1389
1182
tree = self.setup_a_tree()
1390
1183
tree.set_last_revision(revision.NULL_REVISION)
1391
1184
tree.branch.set_last_revision_info(0, revision.NULL_REVISION)
1392
tree.commit('1c', rev_id='1c')
1393
tree.commit('2c', rev_id='2c')
1394
tree.commit('3c', rev_id='3c')
1185
tree.commit('1c', rev_id=b'1c')
1186
tree.commit('2c', rev_id=b'2c')
1187
tree.commit('3c', rev_id=b'3c')
1397
1190
def test_all_new(self):
1398
1191
tree = self.setup_ab_tree()
1399
old, new = log.get_history_change('1a', '3a', tree.branch.repository)
1192
old, new = log.get_history_change(b'1a', b'3a', tree.branch.repository)
1400
1193
self.assertEqual([], old)
1401
self.assertEqual(['2a', '3a'], new)
1194
self.assertEqual([b'2a', b'3a'], new)
1403
1196
def test_all_old(self):
1404
1197
tree = self.setup_ab_tree()
1405
old, new = log.get_history_change('3a', '1a', tree.branch.repository)
1198
old, new = log.get_history_change(b'3a', b'1a', tree.branch.repository)
1406
1199
self.assertEqual([], new)
1407
self.assertEqual(['2a', '3a'], old)
1200
self.assertEqual([b'2a', b'3a'], old)
1409
1202
def test_null_old(self):
1410
1203
tree = self.setup_ab_tree()
1411
1204
old, new = log.get_history_change(revision.NULL_REVISION,
1412
'3a', tree.branch.repository)
1205
b'3a', tree.branch.repository)
1413
1206
self.assertEqual([], old)
1414
self.assertEqual(['1a', '2a', '3a'], new)
1207
self.assertEqual([b'1a', b'2a', b'3a'], new)
1416
1209
def test_null_new(self):
1417
1210
tree = self.setup_ab_tree()
1418
old, new = log.get_history_change('3a', revision.NULL_REVISION,
1211
old, new = log.get_history_change(b'3a', revision.NULL_REVISION,
1419
1212
tree.branch.repository)
1420
1213
self.assertEqual([], new)
1421
self.assertEqual(['1a', '2a', '3a'], old)
1214
self.assertEqual([b'1a', b'2a', b'3a'], old)
1423
1216
def test_diverged(self):
1424
1217
tree = self.setup_ab_tree()
1425
old, new = log.get_history_change('3a', '3b', tree.branch.repository)
1426
self.assertEqual(old, ['2a', '3a'])
1427
self.assertEqual(new, ['2b', '3b'])
1218
old, new = log.get_history_change(b'3a', b'3b', tree.branch.repository)
1219
self.assertEqual(old, [b'2a', b'3a'])
1220
self.assertEqual(new, [b'2b', b'3b'])
1429
1222
def test_unrelated(self):
1430
1223
tree = self.setup_ac_tree()
1431
old, new = log.get_history_change('3a', '3c', tree.branch.repository)
1432
self.assertEqual(old, ['1a', '2a', '3a'])
1433
self.assertEqual(new, ['1c', '2c', '3c'])
1224
old, new = log.get_history_change(b'3a', b'3c', tree.branch.repository)
1225
self.assertEqual(old, [b'1a', b'2a', b'3a'])
1226
self.assertEqual(new, [b'1c', b'2c', b'3c'])
1435
1228
def test_show_branch_change(self):
1436
1229
tree = self.setup_ab_tree()
1438
log.show_branch_change(tree.branch, s, 3, '3a')
1231
log.show_branch_change(tree.branch, s, 3, b'3a')
1439
1232
self.assertContainsRe(s.getvalue(),
1440
'[*]{60}\nRemoved Revisions:\n(.|\n)*2a(.|\n)*3a(.|\n)*'
1441
'[*]{60}\n\nAdded Revisions:\n(.|\n)*2b(.|\n)*3b')
1233
'[*]{60}\nRemoved Revisions:\n(.|\n)*2a(.|\n)*3a(.|\n)*'
1234
'[*]{60}\n\nAdded Revisions:\n(.|\n)*2b(.|\n)*3b')
1443
1236
def test_show_branch_change_no_change(self):
1444
1237
tree = self.setup_ab_tree()
1446
log.show_branch_change(tree.branch, s, 3, '3b')
1239
log.show_branch_change(tree.branch, s, 3, b'3b')
1447
1240
self.assertEqual(s.getvalue(),
1448
'Nothing seems to have changed\n')
1241
'Nothing seems to have changed\n')
1450
1243
def test_show_branch_change_no_old(self):
1451
1244
tree = self.setup_ab_tree()
1453
log.show_branch_change(tree.branch, s, 2, '2b')
1246
log.show_branch_change(tree.branch, s, 2, b'2b')
1454
1247
self.assertContainsRe(s.getvalue(), 'Added Revisions:')
1455
1248
self.assertNotContainsRe(s.getvalue(), 'Removed Revisions:')
1457
1250
def test_show_branch_change_no_new(self):
1458
1251
tree = self.setup_ab_tree()
1459
tree.branch.set_last_revision_info(2, '2b')
1252
tree.branch.set_last_revision_info(2, b'2b')
1461
log.show_branch_change(tree.branch, s, 3, '3b')
1254
log.show_branch_change(tree.branch, s, 3, b'3b')
1462
1255
self.assertContainsRe(s.getvalue(), 'Removed Revisions:')
1463
1256
self.assertNotContainsRe(s.getvalue(), 'Added Revisions:')
1259
class TestRevisionNotInBranch(TestCaseForLogFormatter):
1261
def setup_a_tree(self):
1262
tree = self.make_branch_and_tree('tree')
1264
self.addCleanup(tree.unlock)
1266
'committer': 'Joe Foo <joe@foo.com>',
1267
'timestamp': 1132617600, # Mon 2005-11-22 00:00:00 +0000
1268
'timezone': 0, # UTC
1270
tree.commit('commit 1a', rev_id=b'1a', **kwargs)
1271
tree.commit('commit 2a', rev_id=b'2a', **kwargs)
1272
tree.commit('commit 3a', rev_id=b'3a', **kwargs)
1275
def setup_ab_tree(self):
1276
tree = self.setup_a_tree()
1277
tree.set_last_revision(b'1a')
1278
tree.branch.set_last_revision_info(1, b'1a')
1280
'committer': 'Joe Foo <joe@foo.com>',
1281
'timestamp': 1132617600, # Mon 2005-11-22 00:00:00 +0000
1282
'timezone': 0, # UTC
1284
tree.commit('commit 2b', rev_id=b'2b', **kwargs)
1285
tree.commit('commit 3b', rev_id=b'3b', **kwargs)
1288
def test_one_revision(self):
1289
tree = self.setup_ab_tree()
1291
rev = revisionspec.RevisionInfo(tree.branch, None, b'3a')
1292
log.show_log(tree.branch, lf, verbose=True, start_revision=rev,
1294
self.assertEqual(1, len(lf.revisions))
1295
self.assertEqual(None, lf.revisions[0].revno) # Out-of-branch
1296
self.assertEqual(b'3a', lf.revisions[0].rev.revision_id)
1298
def test_many_revisions(self):
1299
tree = self.setup_ab_tree()
1301
start_rev = revisionspec.RevisionInfo(tree.branch, None, b'1a')
1302
end_rev = revisionspec.RevisionInfo(tree.branch, None, b'3a')
1303
log.show_log(tree.branch, lf, verbose=True, start_revision=start_rev,
1304
end_revision=end_rev)
1305
self.assertEqual(3, len(lf.revisions))
1306
self.assertEqual(None, lf.revisions[0].revno) # Out-of-branch
1307
self.assertEqual(b'3a', lf.revisions[0].rev.revision_id)
1308
self.assertEqual(None, lf.revisions[1].revno) # Out-of-branch
1309
self.assertEqual(b'2a', lf.revisions[1].rev.revision_id)
1310
self.assertEqual('1', lf.revisions[2].revno) # In-branch
1312
def test_long_format(self):
1313
tree = self.setup_ab_tree()
1314
start_rev = revisionspec.RevisionInfo(tree.branch, None, b'1a')
1315
end_rev = revisionspec.RevisionInfo(tree.branch, None, b'3a')
1316
self.assertFormatterResult(b"""\
1317
------------------------------------------------------------
1319
committer: Joe Foo <joe@foo.com>
1321
timestamp: Tue 2005-11-22 00:00:00 +0000
1324
------------------------------------------------------------
1326
committer: Joe Foo <joe@foo.com>
1328
timestamp: Tue 2005-11-22 00:00:00 +0000
1331
------------------------------------------------------------
1333
committer: Joe Foo <joe@foo.com>
1335
timestamp: Tue 2005-11-22 00:00:00 +0000
1339
tree.branch, log.LongLogFormatter, show_log_kwargs={
1340
'start_revision': start_rev, 'end_revision': end_rev
1343
def test_short_format(self):
1344
tree = self.setup_ab_tree()
1345
start_rev = revisionspec.RevisionInfo(tree.branch, None, b'1a')
1346
end_rev = revisionspec.RevisionInfo(tree.branch, None, b'3a')
1347
self.assertFormatterResult(b"""\
1356
1 Joe Foo\t2005-11-22
1360
tree.branch, log.ShortLogFormatter, show_log_kwargs={
1361
'start_revision': start_rev, 'end_revision': end_rev
1364
def test_line_format(self):
1365
tree = self.setup_ab_tree()
1366
start_rev = revisionspec.RevisionInfo(tree.branch, None, b'1a')
1367
end_rev = revisionspec.RevisionInfo(tree.branch, None, b'3a')
1368
self.assertFormatterResult(b"""\
1369
Joe Foo 2005-11-22 commit 3a
1370
Joe Foo 2005-11-22 commit 2a
1371
1: Joe Foo 2005-11-22 commit 1a
1373
tree.branch, log.LineLogFormatter, show_log_kwargs={
1374
'start_revision': start_rev, 'end_revision': end_rev
1467
1378
class TestLogWithBugs(TestCaseForLogFormatter, TestLogMixin):
1469
1380
def setUp(self):
1470
TestCaseForLogFormatter.setUp(self)
1381
super(TestLogWithBugs, self).setUp()
1471
1382
log.properties_handler_registry.register(
1472
1383
'bugs_properties_handler',
1473
1384
log._bugs_properties_handler)
1726
1676
def assertLogRevnos(self, expected_revnos, b, start, end,
1727
exclude_common_ancestry):
1677
exclude_common_ancestry, generate_merge_revisions=True):
1728
1678
# FIXME: the layering in log makes it hard to test intermediate levels,
1729
# I wish adding filters with their parameters were easier...
1679
# I wish adding filters with their parameters was easier...
1730
1680
# -- vila 20100413
1731
1681
iter_revs = log._calc_view_revisions(
1732
1682
b, start, end, direction='reverse',
1733
generate_merge_revisions=True,
1683
generate_merge_revisions=generate_merge_revisions,
1734
1684
exclude_common_ancestry=exclude_common_ancestry)
1735
1685
self.assertEqual(expected_revnos,
1736
1686
[revid for revid, revno, depth in iter_revs])
1738
1688
def test_merge_sorted_exclude_ancestry(self):
1739
1689
b = self.make_branch_with_alternate_ancestries()
1740
self.assertLogRevnos(['3', '1.1.2', '1.2.1', '1.1.1', '2', '1'],
1690
self.assertLogRevnos([b'3', b'1.1.2', b'1.2.1', b'1.1.1', b'2', b'1'],
1691
b, b'1', b'3', exclude_common_ancestry=False)
1742
1692
# '2' is part of the '3' ancestry but not part of '1.1.1' ancestry so
1743
1693
# 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', True)
1695
self.assertLogRevnos([b'3', b'1.1.2', b'1.2.1', b'2'],
1696
b, b'1.1.1', b'3', exclude_common_ancestry=True)
1698
def test_merge_sorted_simple_revnos_exclude_ancestry(self):
1699
b = self.make_branch_with_alternate_ancestries()
1700
self.assertLogRevnos([b'3', b'2'],
1701
b, b'1', b'3', exclude_common_ancestry=True,
1702
generate_merge_revisions=False)
1703
self.assertLogRevnos([b'3', b'1.1.2', b'1.2.1', b'1.1.1', b'2'],
1704
b, b'1', b'3', exclude_common_ancestry=True,
1705
generate_merge_revisions=True)
1708
class TestLogDefaults(TestCaseForLogFormatter):
1709
def test_default_log_level(self):
1711
Test to ensure that specifying 'levels=1' to make_log_request_dict
1712
doesn't get overwritten when using a LogFormatter that supports more
1716
wt = self._prepare_tree_with_merges()
1719
class CustomLogFormatter(log.LogFormatter):
1720
def __init__(self, *args, **kwargs):
1721
super(CustomLogFormatter, self).__init__(*args, **kwargs)
1724
def get_levels(self):
1725
# log formatter supports all levels:
1728
def log_revision(self, revision):
1729
self.revisions.append(revision)
1731
log_formatter = LogCatcher()
1732
# First request we don't specify number of levels, we should get a
1733
# sensible default (whatever the LogFormatter handles - which in this
1734
# case is 0/everything):
1735
request = log.make_log_request_dict(limit=10)
1736
log.Logger(b, request).show(log_formatter)
1737
# should have all three revisions:
1738
self.assertEqual(len(log_formatter.revisions), 3)
1741
log_formatter = LogCatcher()
1742
# now explicitly request mainline revisions only:
1743
request = log.make_log_request_dict(limit=10, levels=1)
1744
log.Logger(b, request).show(log_formatter)
1745
# should now only have 2 revisions:
1746
self.assertEqual(len(log_formatter.revisions), 2)