142
142
lf = LogCatcher()
143
143
log.show_log(wt.branch, lf, verbose=True)
144
144
committed_msg = lf.revisions[0].rev.message
145
self.assertNotEqual(msg, committed_msg)
146
self.assertTrue(len(committed_msg) > len(msg))
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)
148
151
def test_commit_message_without_control_chars(self):
149
152
wt = self.make_branch_and_tree('.')
1198
1201
return mainline_revs, rev_nos, wt
1200
def make_tree_with_many_merges(self):
1203
def make_branch_with_many_merges(self):
1201
1204
"""Create a tree with well-known revision ids"""
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')
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()
1223
1233
mainline_revs = [None, '1', '2', '3c', '4b']
1224
1234
rev_nos = {'1':1, '2':2, '3c': 3, '4b':4}
1231
1241
'4a': '2.2.2', # second commit tree 2
1232
1242
'4b': '4', # merges 4a to main
1234
return mainline_revs, rev_nos, wt
1244
return mainline_revs, rev_nos, builder.get_branch()
1236
1246
def test_get_view_revisions_forward(self):
1237
1247
"""Test the get_view_revisions method"""
1298
1308
def test_get_view_revisions_merge2(self):
1299
1309
"""Test get_view_revisions when there are merges"""
1300
mainline_revs, rev_nos, wt = self.make_tree_with_many_merges()
1302
self.addCleanup(wt.unlock)
1310
mainline_revs, rev_nos, b = self.make_branch_with_many_merges()
1312
self.addCleanup(b.unlock)
1303
1313
revisions = list(log.get_view_revisions(
1304
mainline_revs, rev_nos, wt.branch, 'forward'))
1314
mainline_revs, rev_nos, b, 'forward'))
1305
1315
expected = [('1', '1', 0), ('2', '2', 0), ('3c', '3', 0),
1306
('3a', '2.1.1', 1), ('3b', '2.2.1', 1), ('4b', '4', 0),
1316
('3b', '2.2.1', 1), ('3a', '2.1.1', 2), ('4b', '4', 0),
1307
1317
('4a', '2.2.2', 1)]
1308
1318
self.assertEqual(expected, revisions)
1309
1319
revisions = list(log.get_view_revisions(
1310
mainline_revs, rev_nos, wt.branch, 'forward',
1320
mainline_revs, rev_nos, b, 'forward',
1311
1321
include_merges=False))
1312
1322
self.assertEqual([('1', '1', 0), ('2', '2', 0), ('3c', '3', 0),
1313
1323
('4b', '4', 0)],
1317
1327
def test_file_id_for_range(self):
1318
mainline_revs, rev_nos, wt = self.make_tree_with_many_merges()
1320
self.addCleanup(wt.unlock)
1328
mainline_revs, rev_nos, b = self.make_branch_with_many_merges()
1330
self.addCleanup(b.unlock)
1322
1332
def rev_from_rev_id(revid, branch):
1323
1333
revspec = revisionspec.RevisionSpec.from_string('revid:%s' % revid)
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)],
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)],
1340
1350
view_revs(rev_3a, rev_4b, 'f-id', 'reverse'))
1341
1351
# Note: 3c still appears before 3a here because of depth-based sorting
1342
self.assertEqual([('3c', '3', 0), ('3a', '2.1.1', 1)],
1352
self.assertEqual([('3c', '3', 0), ('3b', '2.2.1', 1), ('3a', '2.1.1', 2)],
1343
1353
view_revs(rev_3a, rev_4b, 'f-id', 'forward'))