1166
1166
merger = self.make_Merger(self.setup_criss_cross_graph(), 'E-id')
1167
1167
self.assertEqual('A-id', merger.base_rev_id)
1168
1168
self.assertTrue(merger._is_criss_cross)
1169
self.assertEqual(['B-id', 'C-id'], sorted(merger._lca_trees.keys()))
1169
self.assertEqual(['B-id', 'C-id'], [t.get_revision_id()
1170
for t in merger._lca_trees])
1171
1172
def test_no_criss_cross_passed_to_merge_type(self):
1172
1173
class LCATreesMerger(LoggingMerger):
1182
1183
merger = self.make_Merger(self.setup_criss_cross_graph(), 'E-id')
1183
1184
merger.merge_type = _mod_merge.Merge3Merger
1184
1185
merge_obj = merger.make_merger()
1185
self.assertEqual(['B-id', 'C-id'], sorted(merge_obj._lca_trees.keys()))
1186
self.assertEqual(['B-id', 'C-id'], [t.get_revision_id()
1187
for t in merger._lca_trees])
1187
1189
def test_criss_cross_not_supported_merge_type(self):
1188
1190
class NoLCATreesMerger(LoggingMerger):
1227
1229
[('modify', ('a-id', 'a\nB\nb\nC\nc\n'))])
1228
1230
merge_obj = self.make_merge_obj(builder, 'E-id')
1230
self.assertEqual(['B-id', 'C-id'], sorted(merge_obj._lca_trees.keys()))
1232
self.assertEqual(['B-id', 'C-id'], [t.get_revision_id()
1233
for t in merge_obj._lca_trees])
1231
1234
self.assertEqual('A-id', merge_obj.base_tree.get_revision_id())
1232
1235
entries = list(merge_obj._entries_lca())
1268
1271
builder.build_snapshot('F-id', ['D-id', 'E-id'], [])
1269
1272
merge_obj = self.make_merge_obj(builder, 'G-id')
1271
self.assertEqual(['D-id', 'E-id'], sorted(merge_obj._lca_trees.keys()))
1274
self.assertEqual(['D-id', 'E-id'], [t.get_revision_id()
1275
for t in merge_obj._lca_trees])
1272
1276
self.assertEqual('A-id', merge_obj.base_tree.get_revision_id())
1273
1277
entries = list(merge_obj._entries_lca())
1274
1278
root_id = 'a-root-id'
1283
1287
builder.build_snapshot('A-id', None,
1284
1288
[('add', (u'', 'a-root-id', 'directory', None)),
1285
1289
('add', (u'a', 'a-id', 'file', 'a\nb\nc\n'))])
1290
builder.build_snapshot('B-id', ['A-id'],
1291
[('modify', ('a-id', 'a\nB\nb\nc\n'))])
1286
1292
builder.build_snapshot('C-id', ['A-id'],
1287
1293
[('modify', ('a-id', 'a\nb\nC\nc\n'))])
1288
builder.build_snapshot('B-id', ['A-id'],
1289
[('modify', ('a-id', 'a\nB\nb\nc\n'))])
1290
1294
builder.build_snapshot('E-id', ['C-id', 'B-id'],
1291
1295
[('modify', ('a-id', 'a\nB\nb\nC\nc\nE\n'))])
1292
1296
builder.build_snapshot('D-id', ['B-id', 'C-id'],
1293
1297
[('unversion', 'a-id')])
1294
1298
merge_obj = self.make_merge_obj(builder, 'E-id')
1296
self.assertEqual(['B-id', 'C-id'], sorted(merge_obj._lca_trees.keys()))
1300
self.assertEqual(['B-id', 'C-id'], [t.get_revision_id()
1301
for t in merge_obj._lca_trees])
1297
1302
self.assertEqual('A-id', merge_obj.base_tree.get_revision_id())
1299
1304
entries = list(merge_obj._entries_lca())
1304
1309
((False, [False, False]), False, None)),
1312
def test_not_in_one_lca(self):
1313
builder = self.get_builder()
1314
builder.build_snapshot('A-id', None,
1315
[('add', (u'', 'a-root-id', 'directory', None))])
1316
builder.build_snapshot('B-id', ['A-id'], [])
1317
builder.build_snapshot('C-id', ['A-id'],
1318
[('add', (u'a', 'a-id', 'file', 'a\nb\nc\n'))])
1319
builder.build_snapshot('E-id', ['C-id', 'B-id'], [])
1320
builder.build_snapshot('D-id', ['B-id', 'C-id'],
1321
[('add', (u'a', 'a-id', 'file', 'a\nb\nc\n'))])
1322
merge_obj = self.make_merge_obj(builder, 'E-id')
1324
self.assertEqual(['B-id', 'C-id'], [t.get_revision_id()
1325
for t in merge_obj._lca_trees])
1326
self.assertEqual('A-id', merge_obj.base_tree.get_revision_id())
1328
entries = list(merge_obj._entries_lca())
1329
root_id = 'a-root-id'
1330
self.assertEqual([('a-id', True,
1331
((None, [None, root_id]), root_id, root_id),
1332
((None, [None, u'a']), u'a', u'a'),
1333
((None, [None, False]), False, False)),
1307
1336
# TODO: cases to test
1308
1337
# simple criss-cross LCAS identical, BASE different
1309
1338
# x-x changed from BASE but identical for all LCAs and tips