142
142
lf = LogCatcher()
143
143
log.show_log(wt.branch, lf, verbose=True)
144
144
committed_msg = lf.revisions[0].rev.message
145
if wt.branch.repository._serializer.squashes_xml_invalid_characters:
146
self.assertNotEqual(msg, committed_msg)
147
self.assertTrue(len(committed_msg) > len(msg))
149
self.assertEqual(msg, committed_msg)
145
self.assertNotEqual(msg, committed_msg)
146
self.assertTrue(len(committed_msg) > len(msg))
151
148
def test_commit_message_without_control_chars(self):
152
149
wt = self.make_branch_and_tree('.')
1201
1198
return mainline_revs, rev_nos, wt
1203
def make_branch_with_many_merges(self):
1200
def make_tree_with_many_merges(self):
1204
1201
"""Create a tree with well-known revision ids"""
1205
builder = self.make_branch_builder('tree1')
1206
builder.start_series()
1207
builder.build_snapshot('1', None, [
1208
('add', ('', 'TREE_ROOT', 'directory', '')),
1209
('add', ('f', 'f-id', 'file', '1\n'))])
1210
builder.build_snapshot('2', ['1'], [])
1211
builder.build_snapshot('3a', ['2'], [
1212
('modify', ('f-id', '1\n2\n3a\n'))])
1213
builder.build_snapshot('3b', ['2', '3a'], [
1214
('modify', ('f-id', '1\n2\n3a\n'))])
1215
builder.build_snapshot('3c', ['2', '3b'], [
1216
('modify', ('f-id', '1\n2\n3a\n'))])
1217
builder.build_snapshot('4a', ['3b'], [])
1218
builder.build_snapshot('4b', ['3c', '4a'], [])
1219
builder.finish_series()
1202
wt = self.make_branch_and_tree('tree1')
1203
self.build_tree_contents([('tree1/f', '1\n')])
1204
wt.add(['f'], ['f-id'])
1205
wt.commit('commit one', rev_id='1')
1206
wt.commit('commit two', rev_id='2')
1208
tree3 = wt.bzrdir.sprout('tree3').open_workingtree()
1209
self.build_tree_contents([('tree3/f', '1\n2\n3a\n')])
1210
tree3.commit('commit three a', rev_id='3a')
1212
tree2 = wt.bzrdir.sprout('tree2').open_workingtree()
1213
tree2.merge_from_branch(tree3.branch)
1214
tree2.commit('commit three b', rev_id='3b')
1216
wt.merge_from_branch(tree2.branch)
1217
wt.commit('commit three c', rev_id='3c')
1218
tree2.commit('four-a', rev_id='4a')
1220
wt.merge_from_branch(tree2.branch)
1221
wt.commit('four-b', rev_id='4b')
1233
1223
mainline_revs = [None, '1', '2', '3c', '4b']
1234
1224
rev_nos = {'1':1, '2':2, '3c': 3, '4b':4}
1241
1231
'4a': '2.2.2', # second commit tree 2
1242
1232
'4b': '4', # merges 4a to main
1244
return mainline_revs, rev_nos, builder.get_branch()
1234
return mainline_revs, rev_nos, wt
1246
1236
def test_get_view_revisions_forward(self):
1247
1237
"""Test the get_view_revisions method"""
1308
1298
def test_get_view_revisions_merge2(self):
1309
1299
"""Test get_view_revisions when there are merges"""
1310
mainline_revs, rev_nos, b = self.make_branch_with_many_merges()
1312
self.addCleanup(b.unlock)
1300
mainline_revs, rev_nos, wt = self.make_tree_with_many_merges()
1302
self.addCleanup(wt.unlock)
1313
1303
revisions = list(log.get_view_revisions(
1314
mainline_revs, rev_nos, b, 'forward'))
1304
mainline_revs, rev_nos, wt.branch, 'forward'))
1315
1305
expected = [('1', '1', 0), ('2', '2', 0), ('3c', '3', 0),
1316
('3b', '2.2.1', 1), ('3a', '2.1.1', 2), ('4b', '4', 0),
1306
('3a', '2.1.1', 1), ('3b', '2.2.1', 1), ('4b', '4', 0),
1317
1307
('4a', '2.2.2', 1)]
1318
1308
self.assertEqual(expected, revisions)
1319
1309
revisions = list(log.get_view_revisions(
1320
mainline_revs, rev_nos, b, 'forward',
1310
mainline_revs, rev_nos, wt.branch, 'forward',
1321
1311
include_merges=False))
1322
1312
self.assertEqual([('1', '1', 0), ('2', '2', 0), ('3c', '3', 0),
1323
1313
('4b', '4', 0)],
1327
1317
def test_file_id_for_range(self):
1328
mainline_revs, rev_nos, b = self.make_branch_with_many_merges()
1330
self.addCleanup(b.unlock)
1318
mainline_revs, rev_nos, wt = self.make_tree_with_many_merges()
1320
self.addCleanup(wt.unlock)
1332
1322
def rev_from_rev_id(revid, branch):
1333
1323
revspec = revisionspec.RevisionSpec.from_string('revid:%s' % revid)
1347
rev_3a = rev_from_rev_id('3a', b)
1348
rev_4b = rev_from_rev_id('4b', b)
1349
self.assertEqual([('3c', '3', 0), ('3b', '2.2.1', 1), ('3a', '2.1.1', 2)],
1337
rev_3a = rev_from_rev_id('3a', wt.branch)
1338
rev_4b = rev_from_rev_id('4b', wt.branch)
1339
self.assertEqual([('3c', '3', 0), ('3a', '2.1.1', 1)],
1350
1340
view_revs(rev_3a, rev_4b, 'f-id', 'reverse'))
1351
1341
# Note: 3c still appears before 3a here because of depth-based sorting
1352
self.assertEqual([('3c', '3', 0), ('3b', '2.2.1', 1), ('3a', '2.1.1', 2)],
1342
self.assertEqual([('3c', '3', 0), ('3a', '2.1.1', 1)],
1353
1343
view_revs(rev_3a, rev_4b, 'f-id', 'forward'))