1109
989
def test_merge_move_and_change(self):
1110
990
self.expectFailure("lca merge doesn't conflict for move and change",
1111
991
super(TestLCAMerge, self).test_merge_move_and_change)
1114
class LoggingMerger(object):
1115
# These seem to be the required attributes
1116
requires_base = False
1117
supports_reprocess = False
1118
supports_show_base = False
1119
supports_cherrypick = False
1120
# We intentionally do not define supports_lca_trees
1122
def __init__(self, *args, **kwargs):
1124
self.kwargs = kwargs
1127
class TestMergerBase(TestCaseWithMemoryTransport):
1128
"""Common functionality for Merger tests that don't write to disk."""
1130
def get_builder(self):
1131
builder = self.make_branch_builder('path')
1132
builder.start_series()
1133
self.addCleanup(builder.finish_series)
1136
def setup_simple_graph(self):
1137
"""Create a simple 3-node graph.
1139
:return: A BranchBuilder
1146
builder = self.get_builder()
1147
builder.build_snapshot('A-id', None,
1148
[('add', ('', None, 'directory', None))])
1149
builder.build_snapshot('C-id', ['A-id'], [])
1150
builder.build_snapshot('B-id', ['A-id'], [])
1153
def setup_criss_cross_graph(self):
1154
"""Create a 5-node graph with a criss-cross.
1156
:return: A BranchBuilder
1163
builder = self.setup_simple_graph()
1164
builder.build_snapshot('E-id', ['C-id', 'B-id'], [])
1165
builder.build_snapshot('D-id', ['B-id', 'C-id'], [])
1168
def make_Merger(self, builder, other_revision_id,
1169
interesting_files=None, interesting_ids=None):
1170
"""Make a Merger object from a branch builder"""
1171
mem_tree = memorytree.MemoryTree.create_on_branch(builder.get_branch())
1172
mem_tree.lock_write()
1173
self.addCleanup(mem_tree.unlock)
1174
merger = _mod_merge.Merger.from_revision_ids(progress.DummyProgress(),
1175
mem_tree, other_revision_id)
1176
merger.set_interesting_files(interesting_files)
1177
# It seems there is no matching function for set_interesting_ids
1178
merger.interesting_ids = interesting_ids
1179
merger.merge_type = _mod_merge.Merge3Merger
1183
class TestMergerInMemory(TestMergerBase):
1185
def test_find_base(self):
1186
merger = self.make_Merger(self.setup_simple_graph(), 'C-id')
1187
self.assertEqual('A-id', merger.base_rev_id)
1188
self.assertFalse(merger._is_criss_cross)
1189
self.assertIs(None, merger._lca_trees)
1191
def test_find_base_criss_cross(self):
1192
builder = self.setup_criss_cross_graph()
1193
merger = self.make_Merger(builder, 'E-id')
1194
self.assertEqual('A-id', merger.base_rev_id)
1195
self.assertTrue(merger._is_criss_cross)
1196
self.assertEqual(['B-id', 'C-id'], [t.get_revision_id()
1197
for t in merger._lca_trees])
1198
# If we swap the order, we should get a different lca order
1199
builder.build_snapshot('F-id', ['E-id'], [])
1200
merger = self.make_Merger(builder, 'D-id')
1201
self.assertEqual(['C-id', 'B-id'], [t.get_revision_id()
1202
for t in merger._lca_trees])
1204
def test_find_base_triple_criss_cross(self):
1207
# B C F # F is merged into both branches
1214
builder = self.setup_criss_cross_graph()
1215
builder.build_snapshot('F-id', ['A-id'], [])
1216
builder.build_snapshot('H-id', ['E-id', 'F-id'], [])
1217
builder.build_snapshot('G-id', ['D-id', 'F-id'], [])
1218
merger = self.make_Merger(builder, 'H-id')
1219
self.assertEqual(['B-id', 'C-id', 'F-id'],
1220
[t.get_revision_id() for t in merger._lca_trees])
1222
def test_no_criss_cross_passed_to_merge_type(self):
1223
class LCATreesMerger(LoggingMerger):
1224
supports_lca_trees = True
1226
merger = self.make_Merger(self.setup_simple_graph(), 'C-id')
1227
merger.merge_type = LCATreesMerger
1228
merge_obj = merger.make_merger()
1229
self.assertIsInstance(merge_obj, LCATreesMerger)
1230
self.assertFalse('lca_trees' in merge_obj.kwargs)
1232
def test_criss_cross_passed_to_merge_type(self):
1233
merger = self.make_Merger(self.setup_criss_cross_graph(), 'E-id')
1234
merger.merge_type = _mod_merge.Merge3Merger
1235
merge_obj = merger.make_merger()
1236
self.assertEqual(['B-id', 'C-id'], [t.get_revision_id()
1237
for t in merger._lca_trees])
1239
def test_criss_cross_not_supported_merge_type(self):
1240
merger = self.make_Merger(self.setup_criss_cross_graph(), 'E-id')
1241
# We explicitly do not define supports_lca_trees
1242
merger.merge_type = LoggingMerger
1243
merge_obj = merger.make_merger()
1244
self.assertIsInstance(merge_obj, LoggingMerger)
1245
self.assertFalse('lca_trees' in merge_obj.kwargs)
1247
def test_criss_cross_unsupported_merge_type(self):
1248
class UnsupportedLCATreesMerger(LoggingMerger):
1249
supports_lca_trees = False
1251
merger = self.make_Merger(self.setup_criss_cross_graph(), 'E-id')
1252
merger.merge_type = UnsupportedLCATreesMerger
1253
merge_obj = merger.make_merger()
1254
self.assertIsInstance(merge_obj, UnsupportedLCATreesMerger)
1255
self.assertFalse('lca_trees' in merge_obj.kwargs)
1258
class TestMergerEntriesLCA(TestMergerBase):
1260
def make_merge_obj(self, builder, other_revision_id,
1261
interesting_files=None, interesting_ids=None):
1262
merger = self.make_Merger(builder, other_revision_id,
1263
interesting_files=interesting_files,
1264
interesting_ids=interesting_ids)
1265
return merger.make_merger()
1267
def test_simple(self):
1268
builder = self.get_builder()
1269
builder.build_snapshot('A-id', None,
1270
[('add', (u'', 'a-root-id', 'directory', None)),
1271
('add', (u'a', 'a-id', 'file', 'a\nb\nc\n'))])
1272
builder.build_snapshot('C-id', ['A-id'],
1273
[('modify', ('a-id', 'a\nb\nC\nc\n'))])
1274
builder.build_snapshot('B-id', ['A-id'],
1275
[('modify', ('a-id', 'a\nB\nb\nc\n'))])
1276
builder.build_snapshot('E-id', ['C-id', 'B-id'],
1277
[('modify', ('a-id', 'a\nB\nb\nC\nc\nE\n'))])
1278
builder.build_snapshot('D-id', ['B-id', 'C-id'],
1279
[('modify', ('a-id', 'a\nB\nb\nC\nc\n'))])
1280
merge_obj = self.make_merge_obj(builder, 'E-id')
1282
self.assertEqual(['B-id', 'C-id'], [t.get_revision_id()
1283
for t in merge_obj._lca_trees])
1284
self.assertEqual('A-id', merge_obj.base_tree.get_revision_id())
1285
entries = list(merge_obj._entries_lca())
1287
# (file_id, changed, parents, names, executable)
1288
# BASE, lca1, lca2, OTHER, THIS
1289
root_id = 'a-root-id'
1290
self.assertEqual([('a-id', True,
1291
((root_id, [root_id, root_id]), root_id, root_id),
1292
((u'a', [u'a', u'a']), u'a', u'a'),
1293
((False, [False, False]), False, False)),
1296
def test_not_in_base(self):
1297
# LCAs all have the same last-modified revision for the file, as do
1298
# the tips, but the base has something different
1299
# A base, doesn't have the file
1301
# B C B introduces 'foo', C introduces 'bar'
1303
# D E D and E now both have 'foo' and 'bar'
1305
# F G the files are now in F, G, D and E, but not in A
1308
builder = self.get_builder()
1309
builder.build_snapshot('A-id', None,
1310
[('add', (u'', 'a-root-id', 'directory', None))])
1311
builder.build_snapshot('B-id', ['A-id'],
1312
[('add', (u'foo', 'foo-id', 'file', 'a\nb\nc\n'))])
1313
builder.build_snapshot('C-id', ['A-id'],
1314
[('add', (u'bar', 'bar-id', 'file', 'd\ne\nf\n'))])
1315
builder.build_snapshot('D-id', ['B-id', 'C-id'],
1316
[('add', (u'bar', 'bar-id', 'file', 'd\ne\nf\n'))])
1317
builder.build_snapshot('E-id', ['C-id', 'B-id'],
1318
[('add', (u'foo', 'foo-id', 'file', 'a\nb\nc\n'))])
1319
builder.build_snapshot('G-id', ['E-id', 'D-id'],
1320
[('modify', (u'bar-id', 'd\ne\nf\nG\n'))])
1321
builder.build_snapshot('F-id', ['D-id', 'E-id'], [])
1322
merge_obj = self.make_merge_obj(builder, 'G-id')
1324
self.assertEqual(['D-id', 'E-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())
1327
entries = list(merge_obj._entries_lca())
1328
root_id = 'a-root-id'
1329
self.assertEqual([('bar-id', True,
1330
((None, [root_id, root_id]), root_id, root_id),
1331
((None, [u'bar', u'bar']), u'bar', u'bar'),
1332
((None, [False, False]), False, False)),
1335
def test_not_in_this(self):
1336
builder = self.get_builder()
1337
builder.build_snapshot('A-id', None,
1338
[('add', (u'', 'a-root-id', 'directory', None)),
1339
('add', (u'a', 'a-id', 'file', 'a\nb\nc\n'))])
1340
builder.build_snapshot('B-id', ['A-id'],
1341
[('modify', ('a-id', 'a\nB\nb\nc\n'))])
1342
builder.build_snapshot('C-id', ['A-id'],
1343
[('modify', ('a-id', 'a\nb\nC\nc\n'))])
1344
builder.build_snapshot('E-id', ['C-id', 'B-id'],
1345
[('modify', ('a-id', 'a\nB\nb\nC\nc\nE\n'))])
1346
builder.build_snapshot('D-id', ['B-id', 'C-id'],
1347
[('unversion', 'a-id')])
1348
merge_obj = self.make_merge_obj(builder, 'E-id')
1350
self.assertEqual(['B-id', 'C-id'], [t.get_revision_id()
1351
for t in merge_obj._lca_trees])
1352
self.assertEqual('A-id', merge_obj.base_tree.get_revision_id())
1354
entries = list(merge_obj._entries_lca())
1355
root_id = 'a-root-id'
1356
self.assertEqual([('a-id', True,
1357
((root_id, [root_id, root_id]), root_id, None),
1358
((u'a', [u'a', u'a']), u'a', None),
1359
((False, [False, False]), False, None)),
1362
def test_file_not_in_one_lca(self):
1365
# B C # B no file, C introduces a file
1367
# D E # D and E both have the file, unchanged from C
1368
builder = self.get_builder()
1369
builder.build_snapshot('A-id', None,
1370
[('add', (u'', 'a-root-id', 'directory', None))])
1371
builder.build_snapshot('B-id', ['A-id'], [])
1372
builder.build_snapshot('C-id', ['A-id'],
1373
[('add', (u'a', 'a-id', 'file', 'a\nb\nc\n'))])
1374
builder.build_snapshot('E-id', ['C-id', 'B-id'], []) # Inherited from C
1375
builder.build_snapshot('D-id', ['B-id', 'C-id'], # Merged from C
1376
[('add', (u'a', 'a-id', 'file', 'a\nb\nc\n'))])
1377
merge_obj = self.make_merge_obj(builder, 'E-id')
1379
self.assertEqual(['B-id', 'C-id'], [t.get_revision_id()
1380
for t in merge_obj._lca_trees])
1381
self.assertEqual('A-id', merge_obj.base_tree.get_revision_id())
1383
entries = list(merge_obj._entries_lca())
1384
self.assertEqual([], entries)
1386
def test_not_in_other(self):
1387
builder = self.get_builder()
1388
builder.build_snapshot('A-id', None,
1389
[('add', (u'', 'a-root-id', 'directory', None)),
1390
('add', (u'a', 'a-id', 'file', 'a\nb\nc\n'))])
1391
builder.build_snapshot('B-id', ['A-id'], [])
1392
builder.build_snapshot('C-id', ['A-id'], [])
1393
builder.build_snapshot('E-id', ['C-id', 'B-id'],
1394
[('unversion', 'a-id')])
1395
builder.build_snapshot('D-id', ['B-id', 'C-id'], [])
1396
merge_obj = self.make_merge_obj(builder, 'E-id')
1398
entries = list(merge_obj._entries_lca())
1399
root_id = 'a-root-id'
1400
self.assertEqual([('a-id', True,
1401
((root_id, [root_id, root_id]), None, root_id),
1402
((u'a', [u'a', u'a']), None, u'a'),
1403
((False, [False, False]), None, False)),
1406
def test_not_in_other_or_lca(self):
1407
# A base, introduces 'foo'
1409
# B C B nothing, C deletes foo
1411
# D E D restores foo (same as B), E leaves it deleted
1413
# A => B, no changes
1414
# A => C, delete foo (C should supersede B)
1415
# C => D, restore foo
1416
# C => E, no changes
1417
# D would then win 'cleanly' and no record would be given
1418
builder = self.get_builder()
1419
builder.build_snapshot('A-id', None,
1420
[('add', (u'', 'a-root-id', 'directory', None)),
1421
('add', (u'foo', 'foo-id', 'file', 'content\n'))])
1422
builder.build_snapshot('B-id', ['A-id'], [])
1423
builder.build_snapshot('C-id', ['A-id'],
1424
[('unversion', 'foo-id')])
1425
builder.build_snapshot('E-id', ['C-id', 'B-id'], [])
1426
builder.build_snapshot('D-id', ['B-id', 'C-id'], [])
1427
merge_obj = self.make_merge_obj(builder, 'E-id')
1429
entries = list(merge_obj._entries_lca())
1430
self.assertEqual([], entries)
1432
def test_not_in_other_mod_in_lca1_not_in_lca2(self):
1433
# A base, introduces 'foo'
1435
# B C B changes 'foo', C deletes foo
1437
# D E D restores foo (same as B), E leaves it deleted (as C)
1439
# A => B, modified foo
1440
# A => C, delete foo, C does not supersede B
1441
# B => D, no changes
1442
# C => D, resolve in favor of B
1443
# B => E, resolve in favor of E
1444
# C => E, no changes
1445
# In this case, we have a conflict of how the changes were resolved. E
1446
# picked C and D picked B, so we should issue a conflict
1447
builder = self.get_builder()
1448
builder.build_snapshot('A-id', None,
1449
[('add', (u'', 'a-root-id', 'directory', None)),
1450
('add', (u'foo', 'foo-id', 'file', 'content\n'))])
1451
builder.build_snapshot('B-id', ['A-id'], [
1452
('modify', ('foo-id', 'new-content\n'))])
1453
builder.build_snapshot('C-id', ['A-id'],
1454
[('unversion', 'foo-id')])
1455
builder.build_snapshot('E-id', ['C-id', 'B-id'], [])
1456
builder.build_snapshot('D-id', ['B-id', 'C-id'], [])
1457
merge_obj = self.make_merge_obj(builder, 'E-id')
1459
entries = list(merge_obj._entries_lca())
1460
root_id = 'a-root-id'
1461
self.assertEqual([('foo-id', True,
1462
((root_id, [root_id, None]), None, root_id),
1463
((u'foo', [u'foo', None]), None, 'foo'),
1464
((False, [False, None]), None, False)),
1467
def test_only_in_one_lca(self):
1470
# B C B nothing, C add file
1472
# D E D still has nothing, E removes file
1475
# C => D, removed the file
1477
# C => E, removed the file
1478
# Thus D & E have identical changes, and this is a no-op
1481
# A => C, add file, thus C supersedes B
1482
# w/ C=BASE, D=THIS, E=OTHER we have 'happy convergence'
1483
builder = self.get_builder()
1484
builder.build_snapshot('A-id', None,
1485
[('add', (u'', 'a-root-id', 'directory', None))])
1486
builder.build_snapshot('B-id', ['A-id'], [])
1487
builder.build_snapshot('C-id', ['A-id'],
1488
[('add', (u'a', 'a-id', 'file', 'a\nb\nc\n'))])
1489
builder.build_snapshot('E-id', ['C-id', 'B-id'],
1490
[('unversion', 'a-id')])
1491
builder.build_snapshot('D-id', ['B-id', 'C-id'], [])
1492
merge_obj = self.make_merge_obj(builder, 'E-id')
1494
entries = list(merge_obj._entries_lca())
1495
self.assertEqual([], entries)
1497
def test_only_in_other(self):
1498
builder = self.get_builder()
1499
builder.build_snapshot('A-id', None,
1500
[('add', (u'', 'a-root-id', 'directory', None))])
1501
builder.build_snapshot('B-id', ['A-id'], [])
1502
builder.build_snapshot('C-id', ['A-id'], [])
1503
builder.build_snapshot('E-id', ['C-id', 'B-id'],
1504
[('add', (u'a', 'a-id', 'file', 'a\nb\nc\n'))])
1505
builder.build_snapshot('D-id', ['B-id', 'C-id'], [])
1506
merge_obj = self.make_merge_obj(builder, 'E-id')
1508
entries = list(merge_obj._entries_lca())
1509
root_id = 'a-root-id'
1510
self.assertEqual([('a-id', True,
1511
((None, [None, None]), root_id, None),
1512
((None, [None, None]), u'a', None),
1513
((None, [None, None]), False, None)),
1516
def test_one_lca_supersedes(self):
1517
# One LCA supersedes the other LCAs last modified value, but the
1518
# value is not the same as BASE.
1519
# A base, introduces 'foo', last mod A
1521
# B C B modifies 'foo' (mod B), C does nothing (mod A)
1523
# D E D does nothing (mod B), E updates 'foo' (mod E)
1525
# F G F updates 'foo' (mod F). G does nothing (mod E)
1527
# At this point, G should not be considered to modify 'foo', even
1528
# though its LCAs disagree. This is because the modification in E
1529
# completely supersedes the value in D.
1530
builder = self.get_builder()
1531
builder.build_snapshot('A-id', None,
1532
[('add', (u'', 'a-root-id', 'directory', None)),
1533
('add', (u'foo', 'foo-id', 'file', 'A content\n'))])
1534
builder.build_snapshot('C-id', ['A-id'], [])
1535
builder.build_snapshot('B-id', ['A-id'],
1536
[('modify', ('foo-id', 'B content\n'))])
1537
builder.build_snapshot('D-id', ['B-id', 'C-id'], [])
1538
builder.build_snapshot('E-id', ['C-id', 'B-id'],
1539
[('modify', ('foo-id', 'E content\n'))])
1540
builder.build_snapshot('G-id', ['E-id', 'D-id'], [])
1541
builder.build_snapshot('F-id', ['D-id', 'E-id'],
1542
[('modify', ('foo-id', 'F content\n'))])
1543
merge_obj = self.make_merge_obj(builder, 'G-id')
1545
self.assertEqual([], list(merge_obj._entries_lca()))
1547
def test_one_lca_supersedes_path(self):
1548
# Double-criss-cross merge, the ultimate base value is different from
1552
# B C B value 'bar', C = 'foo'
1554
# D E D = 'bar', E supersedes to 'bing'
1556
# F G F = 'bing', G supersedes to 'barry'
1558
# In this case, we technically should not care about the value 'bar' for
1559
# D, because it was clearly superseded by E's 'bing'. The
1560
# per-file/attribute graph would actually look like:
1569
# Because the other side of the merge never modifies the value, it just
1570
# takes the value from the merge.
1572
# ATM this fails because we will prune 'foo' from the LCAs, but we
1573
# won't prune 'bar'. This is getting far off into edge-case land, so we
1574
# aren't supporting it yet.
1576
builder = self.get_builder()
1577
builder.build_snapshot('A-id', None,
1578
[('add', (u'', 'a-root-id', 'directory', None)),
1579
('add', (u'foo', 'foo-id', 'file', 'A content\n'))])
1580
builder.build_snapshot('C-id', ['A-id'], [])
1581
builder.build_snapshot('B-id', ['A-id'],
1582
[('rename', ('foo', 'bar'))])
1583
builder.build_snapshot('D-id', ['B-id', 'C-id'], [])
1584
builder.build_snapshot('E-id', ['C-id', 'B-id'],
1585
[('rename', ('foo', 'bing'))]) # override to bing
1586
builder.build_snapshot('G-id', ['E-id', 'D-id'],
1587
[('rename', ('bing', 'barry'))]) # override to barry
1588
builder.build_snapshot('F-id', ['D-id', 'E-id'],
1589
[('rename', ('bar', 'bing'))]) # Merge in E's change
1590
merge_obj = self.make_merge_obj(builder, 'G-id')
1592
self.expectFailure("We don't do an actual heads() check on lca values,"
1593
" or use the per-attribute graph",
1594
self.assertEqual, [], list(merge_obj._entries_lca()))
1596
def test_one_lca_accidentally_pruned(self):
1597
# Another incorrect resolution from the same basic flaw:
1600
# B C B value 'bar', C = 'foo'
1602
# D E D = 'bar', E reverts to 'foo'
1604
# F G F = 'bing', G switches to 'bar'
1606
# 'bar' will not be seen as an interesting change, because 'foo' will
1607
# be pruned from the LCAs, even though it was newly introduced by E
1609
builder = self.get_builder()
1610
builder.build_snapshot('A-id', None,
1611
[('add', (u'', 'a-root-id', 'directory', None)),
1612
('add', (u'foo', 'foo-id', 'file', 'A content\n'))])
1613
builder.build_snapshot('C-id', ['A-id'], [])
1614
builder.build_snapshot('B-id', ['A-id'],
1615
[('rename', ('foo', 'bar'))])
1616
builder.build_snapshot('D-id', ['B-id', 'C-id'], [])
1617
builder.build_snapshot('E-id', ['C-id', 'B-id'], [])
1618
builder.build_snapshot('G-id', ['E-id', 'D-id'],
1619
[('rename', ('foo', 'bar'))])
1620
builder.build_snapshot('F-id', ['D-id', 'E-id'],
1621
[('rename', ('bar', 'bing'))]) # should end up conflicting
1622
merge_obj = self.make_merge_obj(builder, 'G-id')
1624
entries = list(merge_obj._entries_lca())
1625
root_id = 'a-root-id'
1626
self.expectFailure("We prune values from BASE even when relevant.",
1629
((root_id, [root_id, root_id]), root_id, root_id),
1630
((u'foo', [u'bar', u'foo']), u'bar', u'bing'),
1631
((False, [False, False]), False, False)),
1634
def test_both_sides_revert(self):
1635
# Both sides of a criss-cross revert the text to the lca
1636
# A base, introduces 'foo'
1638
# B C B modifies 'foo', C modifies 'foo'
1640
# D E D reverts to B, E reverts to C
1641
# This should conflict
1642
builder = self.get_builder()
1643
builder.build_snapshot('A-id', None,
1644
[('add', (u'', 'a-root-id', 'directory', None)),
1645
('add', (u'foo', 'foo-id', 'file', 'A content\n'))])
1646
builder.build_snapshot('B-id', ['A-id'],
1647
[('modify', ('foo-id', 'B content\n'))])
1648
builder.build_snapshot('C-id', ['A-id'],
1649
[('modify', ('foo-id', 'C content\n'))])
1650
builder.build_snapshot('E-id', ['C-id', 'B-id'], [])
1651
builder.build_snapshot('D-id', ['B-id', 'C-id'], [])
1652
merge_obj = self.make_merge_obj(builder, 'E-id')
1654
entries = list(merge_obj._entries_lca())
1655
root_id = 'a-root-id'
1656
self.assertEqual([('foo-id', True,
1657
((root_id, [root_id, root_id]), root_id, root_id),
1658
((u'foo', [u'foo', u'foo']), u'foo', u'foo'),
1659
((False, [False, False]), False, False)),
1662
def test_different_lca_resolve_one_side_updates_content(self):
1663
# Both sides converge, but then one side updates the text.
1664
# A base, introduces 'foo'
1666
# B C B modifies 'foo', C modifies 'foo'
1668
# D E D reverts to B, E reverts to C
1670
# F F updates to a new value
1671
# We need to emit an entry for 'foo', because D & E differed on the
1673
builder = self.get_builder()
1674
builder.build_snapshot('A-id', None,
1675
[('add', (u'', 'a-root-id', 'directory', None)),
1676
('add', (u'foo', 'foo-id', 'file', 'A content\n'))])
1677
builder.build_snapshot('B-id', ['A-id'],
1678
[('modify', ('foo-id', 'B content\n'))])
1679
builder.build_snapshot('C-id', ['A-id'],
1680
[('modify', ('foo-id', 'C content\n'))])
1681
builder.build_snapshot('E-id', ['C-id', 'B-id'], [])
1682
builder.build_snapshot('D-id', ['B-id', 'C-id'], [])
1683
builder.build_snapshot('F-id', ['D-id'],
1684
[('modify', ('foo-id', 'F content\n'))])
1685
merge_obj = self.make_merge_obj(builder, 'E-id')
1687
entries = list(merge_obj._entries_lca())
1688
root_id = 'a-root-id'
1689
self.assertEqual([('foo-id', True,
1690
((root_id, [root_id, root_id]), root_id, root_id),
1691
((u'foo', [u'foo', u'foo']), u'foo', u'foo'),
1692
((False, [False, False]), False, False)),
1695
def test_same_lca_resolution_one_side_updates_content(self):
1696
# Both sides converge, but then one side updates the text.
1697
# A base, introduces 'foo'
1699
# B C B modifies 'foo', C modifies 'foo'
1701
# D E D and E use C's value
1703
# F F updates to a new value
1704
# I think it is a bug that this conflicts, but we don't have a way to
1705
# detect otherwise. And because of:
1706
# test_different_lca_resolve_one_side_updates_content
1707
# We need to conflict.
1709
builder = self.get_builder()
1710
builder.build_snapshot('A-id', None,
1711
[('add', (u'', 'a-root-id', 'directory', None)),
1712
('add', (u'foo', 'foo-id', 'file', 'A content\n'))])
1713
builder.build_snapshot('B-id', ['A-id'],
1714
[('modify', ('foo-id', 'B content\n'))])
1715
builder.build_snapshot('C-id', ['A-id'],
1716
[('modify', ('foo-id', 'C content\n'))])
1717
builder.build_snapshot('E-id', ['C-id', 'B-id'], [])
1718
builder.build_snapshot('D-id', ['B-id', 'C-id'],
1719
[('modify', ('foo-id', 'C content\n'))]) # Same as E
1720
builder.build_snapshot('F-id', ['D-id'],
1721
[('modify', ('foo-id', 'F content\n'))])
1722
merge_obj = self.make_merge_obj(builder, 'E-id')
1724
entries = list(merge_obj._entries_lca())
1725
self.expectFailure("We don't detect that LCA resolution was the"
1726
" same on both sides",
1727
self.assertEqual, [], entries)
1729
def test_only_path_changed(self):
1730
builder = self.get_builder()
1731
builder.build_snapshot('A-id', None,
1732
[('add', (u'', 'a-root-id', 'directory', None)),
1733
('add', (u'a', 'a-id', 'file', 'content\n'))])
1734
builder.build_snapshot('B-id', ['A-id'], [])
1735
builder.build_snapshot('C-id', ['A-id'], [])
1736
builder.build_snapshot('E-id', ['C-id', 'B-id'],
1737
[('rename', (u'a', u'b'))])
1738
builder.build_snapshot('D-id', ['B-id', 'C-id'], [])
1739
merge_obj = self.make_merge_obj(builder, 'E-id')
1740
entries = list(merge_obj._entries_lca())
1741
root_id = 'a-root-id'
1742
# The content was not changed, only the path
1743
self.assertEqual([('a-id', False,
1744
((root_id, [root_id, root_id]), root_id, root_id),
1745
((u'a', [u'a', u'a']), u'b', u'a'),
1746
((False, [False, False]), False, False)),
1749
def test_kind_changed(self):
1750
# Identical content, except 'D' changes a-id into a directory
1751
builder = self.get_builder()
1752
builder.build_snapshot('A-id', None,
1753
[('add', (u'', 'a-root-id', 'directory', None)),
1754
('add', (u'a', 'a-id', 'file', 'content\n'))])
1755
builder.build_snapshot('B-id', ['A-id'], [])
1756
builder.build_snapshot('C-id', ['A-id'], [])
1757
builder.build_snapshot('E-id', ['C-id', 'B-id'],
1758
[('unversion', 'a-id'),
1759
('add', (u'a', 'a-id', 'directory', None))])
1760
builder.build_snapshot('D-id', ['B-id', 'C-id'], [])
1761
merge_obj = self.make_merge_obj(builder, 'E-id')
1762
entries = list(merge_obj._entries_lca())
1763
root_id = 'a-root-id'
1764
# Only the kind was changed (content)
1765
self.assertEqual([('a-id', True,
1766
((root_id, [root_id, root_id]), root_id, root_id),
1767
((u'a', [u'a', u'a']), u'a', u'a'),
1768
((False, [False, False]), False, False)),
1771
def test_this_changed_kind(self):
1772
# Identical content, but THIS changes a file to a directory
1773
builder = self.get_builder()
1774
builder.build_snapshot('A-id', None,
1775
[('add', (u'', 'a-root-id', 'directory', None)),
1776
('add', (u'a', 'a-id', 'file', 'content\n'))])
1777
builder.build_snapshot('B-id', ['A-id'], [])
1778
builder.build_snapshot('C-id', ['A-id'], [])
1779
builder.build_snapshot('E-id', ['C-id', 'B-id'], [])
1780
builder.build_snapshot('D-id', ['B-id', 'C-id'],
1781
[('unversion', 'a-id'),
1782
('add', (u'a', 'a-id', 'directory', None))])
1783
merge_obj = self.make_merge_obj(builder, 'E-id')
1784
entries = list(merge_obj._entries_lca())
1785
# Only the kind was changed (content)
1786
self.assertEqual([], entries)
1788
def test_interesting_files(self):
1789
# Two files modified, but we should filter one of them
1790
builder = self.get_builder()
1791
builder.build_snapshot('A-id', None,
1792
[('add', (u'', 'a-root-id', 'directory', None)),
1793
('add', (u'a', 'a-id', 'file', 'content\n')),
1794
('add', (u'b', 'b-id', 'file', 'content\n'))])
1795
builder.build_snapshot('B-id', ['A-id'], [])
1796
builder.build_snapshot('C-id', ['A-id'], [])
1797
builder.build_snapshot('E-id', ['C-id', 'B-id'],
1798
[('modify', ('a-id', 'new-content\n')),
1799
('modify', ('b-id', 'new-content\n'))])
1800
builder.build_snapshot('D-id', ['B-id', 'C-id'], [])
1801
merge_obj = self.make_merge_obj(builder, 'E-id',
1802
interesting_files=['b'])
1803
entries = list(merge_obj._entries_lca())
1804
root_id = 'a-root-id'
1805
self.assertEqual([('b-id', True,
1806
((root_id, [root_id, root_id]), root_id, root_id),
1807
((u'b', [u'b', u'b']), u'b', u'b'),
1808
((False, [False, False]), False, False)),
1811
def test_interesting_file_in_this(self):
1812
# This renamed the file, but it should still match the entry in other
1813
builder = self.get_builder()
1814
builder.build_snapshot('A-id', None,
1815
[('add', (u'', 'a-root-id', 'directory', None)),
1816
('add', (u'a', 'a-id', 'file', 'content\n')),
1817
('add', (u'b', 'b-id', 'file', 'content\n'))])
1818
builder.build_snapshot('B-id', ['A-id'], [])
1819
builder.build_snapshot('C-id', ['A-id'], [])
1820
builder.build_snapshot('E-id', ['C-id', 'B-id'],
1821
[('modify', ('a-id', 'new-content\n')),
1822
('modify', ('b-id', 'new-content\n'))])
1823
builder.build_snapshot('D-id', ['B-id', 'C-id'],
1824
[('rename', ('b', 'c'))])
1825
merge_obj = self.make_merge_obj(builder, 'E-id',
1826
interesting_files=['c'])
1827
entries = list(merge_obj._entries_lca())
1828
root_id = 'a-root-id'
1829
self.assertEqual([('b-id', True,
1830
((root_id, [root_id, root_id]), root_id, root_id),
1831
((u'b', [u'b', u'b']), u'b', u'c'),
1832
((False, [False, False]), False, False)),
1835
def test_interesting_file_in_base(self):
1836
# This renamed the file, but it should still match the entry in BASE
1837
builder = self.get_builder()
1838
builder.build_snapshot('A-id', None,
1839
[('add', (u'', 'a-root-id', 'directory', None)),
1840
('add', (u'a', 'a-id', 'file', 'content\n')),
1841
('add', (u'c', 'c-id', 'file', 'content\n'))])
1842
builder.build_snapshot('B-id', ['A-id'],
1843
[('rename', ('c', 'b'))])
1844
builder.build_snapshot('C-id', ['A-id'],
1845
[('rename', ('c', 'b'))])
1846
builder.build_snapshot('E-id', ['C-id', 'B-id'],
1847
[('modify', ('a-id', 'new-content\n')),
1848
('modify', ('c-id', 'new-content\n'))])
1849
builder.build_snapshot('D-id', ['B-id', 'C-id'], [])
1850
merge_obj = self.make_merge_obj(builder, 'E-id',
1851
interesting_files=['c'])
1852
entries = list(merge_obj._entries_lca())
1853
root_id = 'a-root-id'
1854
self.assertEqual([('c-id', True,
1855
((root_id, [root_id, root_id]), root_id, root_id),
1856
((u'c', [u'b', u'b']), u'b', u'b'),
1857
((False, [False, False]), False, False)),
1860
def test_interesting_file_in_lca(self):
1861
# This renamed the file, but it should still match the entry in LCA
1862
builder = self.get_builder()
1863
builder.build_snapshot('A-id', None,
1864
[('add', (u'', 'a-root-id', 'directory', None)),
1865
('add', (u'a', 'a-id', 'file', 'content\n')),
1866
('add', (u'b', 'b-id', 'file', 'content\n'))])
1867
builder.build_snapshot('B-id', ['A-id'],
1868
[('rename', ('b', 'c'))])
1869
builder.build_snapshot('C-id', ['A-id'], [])
1870
builder.build_snapshot('E-id', ['C-id', 'B-id'],
1871
[('modify', ('a-id', 'new-content\n')),
1872
('modify', ('b-id', 'new-content\n'))])
1873
builder.build_snapshot('D-id', ['B-id', 'C-id'],
1874
[('rename', ('c', 'b'))])
1875
merge_obj = self.make_merge_obj(builder, 'E-id',
1876
interesting_files=['c'])
1877
entries = list(merge_obj._entries_lca())
1878
root_id = 'a-root-id'
1879
self.assertEqual([('b-id', True,
1880
((root_id, [root_id, root_id]), root_id, root_id),
1881
((u'b', [u'c', u'b']), u'b', u'b'),
1882
((False, [False, False]), False, False)),
1885
def test_interesting_ids(self):
1886
# Two files modified, but we should filter one of them
1887
builder = self.get_builder()
1888
builder.build_snapshot('A-id', None,
1889
[('add', (u'', 'a-root-id', 'directory', None)),
1890
('add', (u'a', 'a-id', 'file', 'content\n')),
1891
('add', (u'b', 'b-id', 'file', 'content\n'))])
1892
builder.build_snapshot('B-id', ['A-id'], [])
1893
builder.build_snapshot('C-id', ['A-id'], [])
1894
builder.build_snapshot('E-id', ['C-id', 'B-id'],
1895
[('modify', ('a-id', 'new-content\n')),
1896
('modify', ('b-id', 'new-content\n'))])
1897
builder.build_snapshot('D-id', ['B-id', 'C-id'], [])
1898
merge_obj = self.make_merge_obj(builder, 'E-id',
1899
interesting_ids=['b-id'])
1900
entries = list(merge_obj._entries_lca())
1901
root_id = 'a-root-id'
1902
self.assertEqual([('b-id', True,
1903
((root_id, [root_id, root_id]), root_id, root_id),
1904
((u'b', [u'b', u'b']), u'b', u'b'),
1905
((False, [False, False]), False, False)),
1910
class TestMergerEntriesLCAOnDisk(tests.TestCaseWithTransport):
1912
def get_builder(self):
1913
builder = self.make_branch_builder('path')
1914
builder.start_series()
1915
self.addCleanup(builder.finish_series)
1918
def get_wt_from_builder(self, builder):
1919
"""Get a real WorkingTree from the builder."""
1920
the_branch = builder.get_branch()
1921
wt = the_branch.bzrdir.create_workingtree()
1922
# Note: This is a little bit ugly, but we are holding the branch
1923
# write-locked as part of the build process, and we would like to
1924
# maintain that. So we just force the WT to re-use the same
1926
wt._branch = the_branch
1928
self.addCleanup(wt.unlock)
1931
def do_merge(self, builder, other_revision_id):
1932
wt = self.get_wt_from_builder(builder)
1933
merger = _mod_merge.Merger.from_revision_ids(progress.DummyProgress(),
1934
wt, other_revision_id)
1935
merger.merge_type = _mod_merge.Merge3Merger
1936
return wt, merger.do_merge()
1938
def test_simple_lca(self):
1939
builder = self.get_builder()
1940
builder.build_snapshot('A-id', None,
1941
[('add', (u'', 'a-root-id', 'directory', None)),
1942
('add', (u'a', 'a-id', 'file', 'a\nb\nc\n'))])
1943
builder.build_snapshot('C-id', ['A-id'], [])
1944
builder.build_snapshot('B-id', ['A-id'], [])
1945
builder.build_snapshot('E-id', ['C-id', 'B-id'], [])
1946
builder.build_snapshot('D-id', ['B-id', 'C-id'],
1947
[('modify', ('a-id', 'a\nb\nc\nd\ne\nf\n'))])
1948
wt, conflicts = self.do_merge(builder, 'E-id')
1949
self.assertEqual(0, conflicts)
1950
# The merge should have simply update the contents of 'a'
1951
self.assertEqual('a\nb\nc\nd\ne\nf\n', wt.get_file_text('a-id'))
1953
def test_conflict_without_lca(self):
1954
# This test would cause a merge conflict, unless we use the lca trees
1955
# to determine the real ancestry
1958
# B C Path renamed to 'bar' in B
1962
# D E Path at 'bar' in D and E
1964
# F Path at 'baz' in F, which supersedes 'bar' and 'foo'
1965
builder = self.get_builder()
1966
builder.build_snapshot('A-id', None,
1967
[('add', (u'', 'a-root-id', 'directory', None)),
1968
('add', (u'foo', 'foo-id', 'file', 'a\nb\nc\n'))])
1969
builder.build_snapshot('C-id', ['A-id'], [])
1970
builder.build_snapshot('B-id', ['A-id'],
1971
[('rename', ('foo', 'bar'))])
1972
builder.build_snapshot('E-id', ['C-id', 'B-id'], # merge the rename
1973
[('rename', ('foo', 'bar'))])
1974
builder.build_snapshot('F-id', ['E-id'],
1975
[('rename', ('bar', 'baz'))])
1976
builder.build_snapshot('D-id', ['B-id', 'C-id'], [])
1977
wt, conflicts = self.do_merge(builder, 'F-id')
1978
self.assertEqual(0, conflicts)
1979
# The merge should simply recognize that the final rename takes
1981
self.assertEqual('baz', wt.id2path('foo-id'))
1983
def test_other_deletes_lca_renames(self):
1984
# This test would cause a merge conflict, unless we use the lca trees
1985
# to determine the real ancestry
1988
# B C Path renamed to 'bar' in B
1992
# D E Path at 'bar' in D and E
1995
builder = self.get_builder()
1996
builder.build_snapshot('A-id', None,
1997
[('add', (u'', 'a-root-id', 'directory', None)),
1998
('add', (u'foo', 'foo-id', 'file', 'a\nb\nc\n'))])
1999
builder.build_snapshot('C-id', ['A-id'], [])
2000
builder.build_snapshot('B-id', ['A-id'],
2001
[('rename', ('foo', 'bar'))])
2002
builder.build_snapshot('E-id', ['C-id', 'B-id'], # merge the rename
2003
[('rename', ('foo', 'bar'))])
2004
builder.build_snapshot('F-id', ['E-id'],
2005
[('unversion', 'foo-id')])
2006
builder.build_snapshot('D-id', ['B-id', 'C-id'], [])
2007
wt, conflicts = self.do_merge(builder, 'F-id')
2008
self.assertEqual(0, conflicts)
2009
self.assertRaises(errors.NoSuchId, wt.id2path, 'foo-id')
2011
def test_executable_changes(self):
2020
# F Executable bit changed
2021
builder = self.get_builder()
2022
builder.build_snapshot('A-id', None,
2023
[('add', (u'', 'a-root-id', 'directory', None)),
2024
('add', (u'foo', 'foo-id', 'file', 'a\nb\nc\n'))])
2025
builder.build_snapshot('C-id', ['A-id'], [])
2026
builder.build_snapshot('B-id', ['A-id'], [])
2027
builder.build_snapshot('D-id', ['B-id', 'C-id'], [])
2028
builder.build_snapshot('E-id', ['C-id', 'B-id'], [])
2029
# Have to use a real WT, because BranchBuilder doesn't support exec bit
2030
wt = self.get_wt_from_builder(builder)
2031
tt = transform.TreeTransform(wt)
2033
tt.set_executability(True, tt.trans_id_tree_file_id('foo-id'))
2038
self.assertTrue(wt.is_executable('foo-id'))
2039
wt.commit('F-id', rev_id='F-id')
2040
# Reset to D, so that we can merge F
2041
wt.set_parent_ids(['D-id'])
2042
wt.branch.set_last_revision_info(3, 'D-id')
2044
self.assertFalse(wt.is_executable('foo-id'))
2045
conflicts = wt.merge_from_branch(wt.branch, to_revision='F-id')
2046
self.assertEqual(0, conflicts)
2047
self.assertTrue(wt.is_executable('foo-id'))
2049
def test_create_symlink(self):
2050
self.requireFeature(tests.SymlinkFeature)
2059
# F Add a symlink 'foo' => 'bar'
2060
# Have to use a real WT, because BranchBuilder and MemoryTree don't
2061
# have symlink support
2062
builder = self.get_builder()
2063
builder.build_snapshot('A-id', None,
2064
[('add', (u'', 'a-root-id', 'directory', None))])
2065
builder.build_snapshot('C-id', ['A-id'], [])
2066
builder.build_snapshot('B-id', ['A-id'], [])
2067
builder.build_snapshot('D-id', ['B-id', 'C-id'], [])
2068
builder.build_snapshot('E-id', ['C-id', 'B-id'], [])
2069
# Have to use a real WT, because BranchBuilder doesn't support exec bit
2070
wt = self.get_wt_from_builder(builder)
2071
os.symlink('bar', 'path/foo')
2072
wt.add(['foo'], ['foo-id'])
2073
self.assertEqual('bar', wt.get_symlink_target('foo-id'))
2074
wt.commit('add symlink', rev_id='F-id')
2075
# Reset to D, so that we can merge F
2076
wt.set_parent_ids(['D-id'])
2077
wt.branch.set_last_revision_info(3, 'D-id')
2079
self.assertIs(None, wt.path2id('foo'))
2080
conflicts = wt.merge_from_branch(wt.branch, to_revision='F-id')
2081
self.assertEqual(0, conflicts)
2082
self.assertEqual('foo-id', wt.path2id('foo'))
2083
self.assertEqual('bar', wt.get_symlink_target('foo-id'))
2085
def test_both_sides_revert(self):
2086
# Both sides of a criss-cross revert the text to the lca
2087
# A base, introduces 'foo'
2089
# B C B modifies 'foo', C modifies 'foo'
2091
# D E D reverts to B, E reverts to C
2092
# This should conflict
2093
# This must be done with a real WorkingTree, because normally their
2094
# inventory contains "None" rather than a real sha1
2095
builder = self.get_builder()
2096
builder.build_snapshot('A-id', None,
2097
[('add', (u'', 'a-root-id', 'directory', None)),
2098
('add', (u'foo', 'foo-id', 'file', 'A content\n'))])
2099
builder.build_snapshot('B-id', ['A-id'],
2100
[('modify', ('foo-id', 'B content\n'))])
2101
builder.build_snapshot('C-id', ['A-id'],
2102
[('modify', ('foo-id', 'C content\n'))])
2103
builder.build_snapshot('E-id', ['C-id', 'B-id'], [])
2104
builder.build_snapshot('D-id', ['B-id', 'C-id'], [])
2105
wt, conflicts = self.do_merge(builder, 'E-id')
2106
self.assertEqual(1, conflicts)
2107
self.assertEqualDiff('<<<<<<< TREE\n'
2111
'>>>>>>> MERGE-SOURCE\n',
2112
wt.get_file_text('foo-id'))
2114
def test_modified_symlink(self):
2115
self.requireFeature(tests.SymlinkFeature)
2116
# A Create symlink foo => bar
2118
# B C B relinks foo => baz
2122
# D E D & E have foo => baz
2124
# F F changes it to bing
2126
# Merging D & F should result in F cleanly overriding D, because D's
2127
# value actually comes from B
2129
# Have to use a real WT, because BranchBuilder and MemoryTree don't
2130
# have symlink support
2131
wt = self.make_branch_and_tree('path')
2133
self.addCleanup(wt.unlock)
2134
os.symlink('bar', 'path/foo')
2135
wt.add(['foo'], ['foo-id'])
2136
wt.commit('add symlink', rev_id='A-id')
2137
os.remove('path/foo')
2138
os.symlink('baz', 'path/foo')
2139
wt.commit('foo => baz', rev_id='B-id')
2140
wt.set_last_revision('A-id')
2141
wt.branch.set_last_revision_info(1, 'A-id')
2143
wt.commit('C', rev_id='C-id')
2144
wt.merge_from_branch(wt.branch, 'B-id')
2145
self.assertEqual('baz', wt.get_symlink_target('foo-id'))
2146
wt.commit('E merges C & B', rev_id='E-id')
2147
os.remove('path/foo')
2148
os.symlink('bing', 'path/foo')
2149
wt.commit('F foo => bing', rev_id='F-id')
2150
wt.set_last_revision('B-id')
2151
wt.branch.set_last_revision_info(2, 'B-id')
2153
wt.merge_from_branch(wt.branch, 'C-id')
2154
wt.commit('D merges B & C', rev_id='D-id')
2155
conflicts = wt.merge_from_branch(wt.branch, to_revision='F-id')
2156
self.assertEqual(0, conflicts)
2157
self.assertEqual('bing', wt.get_symlink_target('foo-id'))
2159
def test_renamed_symlink(self):
2160
self.requireFeature(tests.SymlinkFeature)
2161
# A Create symlink foo => bar
2163
# B C B renames foo => barry
2167
# D E D & E have barry
2169
# F F renames barry to blah
2171
# Merging D & F should result in F cleanly overriding D, because D's
2172
# value actually comes from B
2174
wt = self.make_branch_and_tree('path')
2176
self.addCleanup(wt.unlock)
2177
os.symlink('bar', 'path/foo')
2178
wt.add(['foo'], ['foo-id'])
2179
wt.commit('A add symlink', rev_id='A-id')
2180
wt.rename_one('foo', 'barry')
2181
wt.commit('B foo => barry', rev_id='B-id')
2182
wt.set_last_revision('A-id')
2183
wt.branch.set_last_revision_info(1, 'A-id')
2185
wt.commit('C', rev_id='C-id')
2186
wt.merge_from_branch(wt.branch, 'B-id')
2187
self.assertEqual('barry', wt.id2path('foo-id'))
2188
self.assertEqual('bar', wt.get_symlink_target('foo-id'))
2189
wt.commit('E merges C & B', rev_id='E-id')
2190
wt.rename_one('barry', 'blah')
2191
wt.commit('F barry => blah', rev_id='F-id')
2192
wt.set_last_revision('B-id')
2193
wt.branch.set_last_revision_info(2, 'B-id')
2195
wt.merge_from_branch(wt.branch, 'C-id')
2196
wt.commit('D merges B & C', rev_id='D-id')
2197
self.assertEqual('barry', wt.id2path('foo-id'))
2198
# Check the output of the Merger object directly
2199
merger = _mod_merge.Merger.from_revision_ids(progress.DummyProgress(),
2201
merger.merge_type = _mod_merge.Merge3Merger
2202
merge_obj = merger.make_merger()
2203
root_id = wt.path2id('')
2204
entries = list(merge_obj._entries_lca())
2205
# No content change, just a path change
2206
self.assertEqual([('foo-id', False,
2207
((root_id, [root_id, root_id]), root_id, root_id),
2208
((u'foo', [u'barry', u'foo']), u'blah', u'barry'),
2209
((False, [False, False]), False, False)),
2211
conflicts = wt.merge_from_branch(wt.branch, to_revision='F-id')
2212
self.assertEqual(0, conflicts)
2213
self.assertEqual('blah', wt.id2path('foo-id'))
2215
def test_symlink_no_content_change(self):
2216
self.requireFeature(tests.SymlinkFeature)
2217
# A Create symlink foo => bar
2219
# B C B relinks foo => baz
2223
# D E D & E have foo => baz
2225
# F F has foo => bing
2227
# Merging E into F should not cause a conflict, because E doesn't have
2228
# a content change relative to the LCAs (it does relative to A)
2229
wt = self.make_branch_and_tree('path')
2231
self.addCleanup(wt.unlock)
2232
os.symlink('bar', 'path/foo')
2233
wt.add(['foo'], ['foo-id'])
2234
wt.commit('add symlink', rev_id='A-id')
2235
os.remove('path/foo')
2236
os.symlink('baz', 'path/foo')
2237
wt.commit('foo => baz', rev_id='B-id')
2238
wt.set_last_revision('A-id')
2239
wt.branch.set_last_revision_info(1, 'A-id')
2241
wt.commit('C', rev_id='C-id')
2242
wt.merge_from_branch(wt.branch, 'B-id')
2243
self.assertEqual('baz', wt.get_symlink_target('foo-id'))
2244
wt.commit('E merges C & B', rev_id='E-id')
2245
wt.set_last_revision('B-id')
2246
wt.branch.set_last_revision_info(2, 'B-id')
2248
wt.merge_from_branch(wt.branch, 'C-id')
2249
wt.commit('D merges B & C', rev_id='D-id')
2250
os.remove('path/foo')
2251
os.symlink('bing', 'path/foo')
2252
wt.commit('F foo => bing', rev_id='F-id')
2254
# Check the output of the Merger object directly
2255
merger = _mod_merge.Merger.from_revision_ids(progress.DummyProgress(),
2257
merger.merge_type = _mod_merge.Merge3Merger
2258
merge_obj = merger.make_merger()
2259
# Nothing interesting happened in OTHER relative to BASE
2260
self.assertEqual([], list(merge_obj._entries_lca()))
2261
# Now do a real merge, just to test the rest of the stack
2262
conflicts = wt.merge_from_branch(wt.branch, to_revision='E-id')
2263
self.assertEqual(0, conflicts)
2264
self.assertEqual('bing', wt.get_symlink_target('foo-id'))
2266
def test_symlink_this_changed_kind(self):
2267
self.requireFeature(tests.SymlinkFeature)
2270
# B C B creates symlink foo => bar
2274
# D E D changes foo into a file, E has foo => bing
2276
# Mostly, this is trying to test that we don't try to os.readlink() on
2277
# a file, or when there is nothing there
2278
wt = self.make_branch_and_tree('path')
2280
self.addCleanup(wt.unlock)
2281
wt.commit('base', rev_id='A-id')
2282
os.symlink('bar', 'path/foo')
2283
wt.add(['foo'], ['foo-id'])
2284
wt.commit('add symlink foo => bar', rev_id='B-id')
2285
wt.set_last_revision('A-id')
2286
wt.branch.set_last_revision_info(1, 'A-id')
2288
wt.commit('C', rev_id='C-id')
2289
wt.merge_from_branch(wt.branch, 'B-id')
2290
self.assertEqual('bar', wt.get_symlink_target('foo-id'))
2291
os.remove('path/foo')
2292
# We have to change the link in E, or it won't try to do a comparison
2293
os.symlink('bing', 'path/foo')
2294
wt.commit('E merges C & B, overrides to bing', rev_id='E-id')
2295
wt.set_last_revision('B-id')
2296
wt.branch.set_last_revision_info(2, 'B-id')
2298
wt.merge_from_branch(wt.branch, 'C-id')
2299
os.remove('path/foo')
2300
self.build_tree_contents([('path/foo', 'file content\n')])
2301
# XXX: workaround, WT doesn't detect kind changes unless you do
2303
list(wt.iter_changes(wt.basis_tree()))
2304
wt.commit('D merges B & C, makes it a file', rev_id='D-id')
2306
merger = _mod_merge.Merger.from_revision_ids(progress.DummyProgress(),
2308
merger.merge_type = _mod_merge.Merge3Merger
2309
merge_obj = merger.make_merger()
2310
entries = list(merge_obj._entries_lca())
2311
root_id = wt.path2id('')
2312
self.assertEqual([('foo-id', True,
2313
((None, [root_id, None]), root_id, root_id),
2314
((None, [u'foo', None]), u'foo', u'foo'),
2315
((None, [False, None]), False, False)),
2318
def test_symlink_all_wt(self):
2319
"""Check behavior if all trees are Working Trees."""
2320
self.requireFeature(tests.SymlinkFeature)
2321
# The big issue is that entry.symlink_target is None for WorkingTrees.
2322
# So we need to make sure we handle that case correctly.
2325
# B C B relinks foo => baz
2327
# D E D & E have foo => baz
2329
# F F changes it to bing
2330
# Merging D & F should result in F cleanly overriding D, because D's
2331
# value actually comes from B
2333
wt = self.make_branch_and_tree('path')
2335
self.addCleanup(wt.unlock)
2336
os.symlink('bar', 'path/foo')
2337
wt.add(['foo'], ['foo-id'])
2338
wt.commit('add symlink', rev_id='A-id')
2339
os.remove('path/foo')
2340
os.symlink('baz', 'path/foo')
2341
wt.commit('foo => baz', rev_id='B-id')
2342
wt.set_last_revision('A-id')
2343
wt.branch.set_last_revision_info(1, 'A-id')
2345
wt.commit('C', rev_id='C-id')
2346
wt.merge_from_branch(wt.branch, 'B-id')
2347
self.assertEqual('baz', wt.get_symlink_target('foo-id'))
2348
wt.commit('E merges C & B', rev_id='E-id')
2349
os.remove('path/foo')
2350
os.symlink('bing', 'path/foo')
2351
wt.commit('F foo => bing', rev_id='F-id')
2352
wt.set_last_revision('B-id')
2353
wt.branch.set_last_revision_info(2, 'B-id')
2355
wt.merge_from_branch(wt.branch, 'C-id')
2356
wt.commit('D merges B & C', rev_id='D-id')
2357
wt_base = wt.bzrdir.sprout('base', 'A-id').open_workingtree()
2359
self.addCleanup(wt_base.unlock)
2360
wt_lca1 = wt.bzrdir.sprout('b-tree', 'B-id').open_workingtree()
2362
self.addCleanup(wt_lca1.unlock)
2363
wt_lca2 = wt.bzrdir.sprout('c-tree', 'C-id').open_workingtree()
2365
self.addCleanup(wt_lca2.unlock)
2366
wt_other = wt.bzrdir.sprout('other', 'F-id').open_workingtree()
2367
wt_other.lock_read()
2368
self.addCleanup(wt_other.unlock)
2369
merge_obj = _mod_merge.Merge3Merger(wt, wt, wt_base,
2370
wt_other, lca_trees=[wt_lca1, wt_lca2], do_merge=False)
2371
entries = list(merge_obj._entries_lca())
2372
root_id = wt.path2id('')
2373
self.assertEqual([('foo-id', True,
2374
((root_id, [root_id, root_id]), root_id, root_id),
2375
((u'foo', [u'foo', u'foo']), u'foo', u'foo'),
2376
((False, [False, False]), False, False)),
2379
def test_other_reverted_path_to_base(self):
2382
# B C Path at 'bar' in B
2389
builder = self.get_builder()
2390
builder.build_snapshot('A-id', None,
2391
[('add', (u'', 'a-root-id', 'directory', None)),
2392
('add', (u'foo', 'foo-id', 'file', 'a\nb\nc\n'))])
2393
builder.build_snapshot('C-id', ['A-id'], [])
2394
builder.build_snapshot('B-id', ['A-id'],
2395
[('rename', ('foo', 'bar'))])
2396
builder.build_snapshot('E-id', ['C-id', 'B-id'],
2397
[('rename', ('foo', 'bar'))]) # merge the rename
2398
builder.build_snapshot('F-id', ['E-id'],
2399
[('rename', ('bar', 'foo'))]) # Rename back to BASE
2400
builder.build_snapshot('D-id', ['B-id', 'C-id'], [])
2401
wt, conflicts = self.do_merge(builder, 'F-id')
2402
self.assertEqual(0, conflicts)
2403
self.assertEqual('foo', wt.id2path('foo-id'))
2405
def test_other_reverted_content_to_base(self):
2406
builder = self.get_builder()
2407
builder.build_snapshot('A-id', None,
2408
[('add', (u'', 'a-root-id', 'directory', None)),
2409
('add', (u'foo', 'foo-id', 'file', 'base content\n'))])
2410
builder.build_snapshot('C-id', ['A-id'], [])
2411
builder.build_snapshot('B-id', ['A-id'],
2412
[('modify', ('foo-id', 'B content\n'))])
2413
builder.build_snapshot('E-id', ['C-id', 'B-id'],
2414
[('modify', ('foo-id', 'B content\n'))]) # merge the content
2415
builder.build_snapshot('F-id', ['E-id'],
2416
[('modify', ('foo-id', 'base content\n'))]) # Revert back to BASE
2417
builder.build_snapshot('D-id', ['B-id', 'C-id'], [])
2418
wt, conflicts = self.do_merge(builder, 'F-id')
2419
self.assertEqual(0, conflicts)
2420
# TODO: We need to use the per-file graph to properly select a BASE
2421
# before this will work. Or at least use the LCA trees to find
2422
# the appropriate content base. (which is B, not A).
2423
self.assertEqual('base content\n', wt.get_file_text('foo-id'))
2425
def test_other_modified_content(self):
2426
builder = self.get_builder()
2427
builder.build_snapshot('A-id', None,
2428
[('add', (u'', 'a-root-id', 'directory', None)),
2429
('add', (u'foo', 'foo-id', 'file', 'base content\n'))])
2430
builder.build_snapshot('C-id', ['A-id'], [])
2431
builder.build_snapshot('B-id', ['A-id'],
2432
[('modify', ('foo-id', 'B content\n'))])
2433
builder.build_snapshot('E-id', ['C-id', 'B-id'],
2434
[('modify', ('foo-id', 'B content\n'))]) # merge the content
2435
builder.build_snapshot('F-id', ['E-id'],
2436
[('modify', ('foo-id', 'F content\n'))]) # Override B content
2437
builder.build_snapshot('D-id', ['B-id', 'C-id'], [])
2438
wt, conflicts = self.do_merge(builder, 'F-id')
2439
self.assertEqual(0, conflicts)
2440
self.assertEqual('F content\n', wt.get_file_text('foo-id'))
2442
def test_all_wt(self):
2443
"""Check behavior if all trees are Working Trees."""
2444
# The big issue is that entry.revision is None for WorkingTrees. (as is
2445
# entry.text_sha1, etc. So we need to make sure we handle that case
2447
# A Content of 'foo', path of 'a'
2449
# B C B modifies content, C renames 'a' => 'b'
2451
# D E E updates content, renames 'b' => 'c'
2452
builder = self.get_builder()
2453
builder.build_snapshot('A-id', None,
2454
[('add', (u'', 'a-root-id', 'directory', None)),
2455
('add', (u'a', 'a-id', 'file', 'base content\n')),
2456
('add', (u'foo', 'foo-id', 'file', 'base content\n'))])
2457
builder.build_snapshot('B-id', ['A-id'],
2458
[('modify', ('foo-id', 'B content\n'))])
2459
builder.build_snapshot('C-id', ['A-id'],
2460
[('rename', ('a', 'b'))])
2461
builder.build_snapshot('E-id', ['C-id', 'B-id'],
2462
[('rename', ('b', 'c')),
2463
('modify', ('foo-id', 'E content\n'))])
2464
builder.build_snapshot('D-id', ['B-id', 'C-id'],
2465
[('rename', ('a', 'b'))]) # merged change
2466
wt_this = self.get_wt_from_builder(builder)
2467
wt_base = wt_this.bzrdir.sprout('base', 'A-id').open_workingtree()
2469
self.addCleanup(wt_base.unlock)
2470
wt_lca1 = wt_this.bzrdir.sprout('b-tree', 'B-id').open_workingtree()
2472
self.addCleanup(wt_lca1.unlock)
2473
wt_lca2 = wt_this.bzrdir.sprout('c-tree', 'C-id').open_workingtree()
2475
self.addCleanup(wt_lca2.unlock)
2476
wt_other = wt_this.bzrdir.sprout('other', 'E-id').open_workingtree()
2477
wt_other.lock_read()
2478
self.addCleanup(wt_other.unlock)
2479
merge_obj = _mod_merge.Merge3Merger(wt_this, wt_this, wt_base,
2480
wt_other, lca_trees=[wt_lca1, wt_lca2], do_merge=False)
2481
entries = list(merge_obj._entries_lca())
2482
root_id = 'a-root-id'
2483
self.assertEqual([('a-id', False,
2484
((root_id, [root_id, root_id]), root_id, root_id),
2485
((u'a', [u'a', u'b']), u'c', u'b'),
2486
((False, [False, False]), False, False)),
2488
((root_id, [root_id, root_id]), root_id, root_id),
2489
((u'foo', [u'foo', u'foo']), u'foo', u'foo'),
2490
((False, [False, False]), False, False)),
2493
def test_nested_tree_unmodified(self):
2494
# Tested with a real WT, because BranchBuilder/MemoryTree don't handle
2496
wt = self.make_branch_and_tree('tree',
2497
format='dirstate-with-subtree')
2499
self.addCleanup(wt.unlock)
2500
sub_tree = self.make_branch_and_tree('tree/sub-tree',
2501
format='dirstate-with-subtree')
2502
wt.set_root_id('a-root-id')
2503
sub_tree.set_root_id('sub-tree-root')
2504
self.build_tree_contents([('tree/sub-tree/file', 'text1')])
2505
sub_tree.add('file')
2506
sub_tree.commit('foo', rev_id='sub-A-id')
2507
wt.add_reference(sub_tree)
2508
wt.commit('set text to 1', rev_id='A-id', recursive=None)
2509
# Now create a criss-cross merge in the parent, without modifying the
2511
wt.commit('B', rev_id='B-id', recursive=None)
2512
wt.set_last_revision('A-id')
2513
wt.branch.set_last_revision_info(1, 'A-id')
2514
wt.commit('C', rev_id='C-id', recursive=None)
2515
wt.merge_from_branch(wt.branch, to_revision='B-id')
2516
wt.commit('E', rev_id='E-id', recursive=None)
2517
wt.set_parent_ids(['B-id', 'C-id'])
2518
wt.branch.set_last_revision_info(2, 'B-id')
2519
wt.commit('D', rev_id='D-id', recursive=None)
2521
merger = _mod_merge.Merger.from_revision_ids(progress.DummyProgress(),
2523
merger.merge_type = _mod_merge.Merge3Merger
2524
merge_obj = merger.make_merger()
2525
entries = list(merge_obj._entries_lca())
2526
self.assertEqual([], entries)
2528
def test_nested_tree_subtree_modified(self):
2529
# Tested with a real WT, because BranchBuilder/MemoryTree don't handle
2531
wt = self.make_branch_and_tree('tree',
2532
format='dirstate-with-subtree')
2534
self.addCleanup(wt.unlock)
2535
sub_tree = self.make_branch_and_tree('tree/sub',
2536
format='dirstate-with-subtree')
2537
wt.set_root_id('a-root-id')
2538
sub_tree.set_root_id('sub-tree-root')
2539
self.build_tree_contents([('tree/sub/file', 'text1')])
2540
sub_tree.add('file')
2541
sub_tree.commit('foo', rev_id='sub-A-id')
2542
wt.add_reference(sub_tree)
2543
wt.commit('set text to 1', rev_id='A-id', recursive=None)
2544
# Now create a criss-cross merge in the parent, without modifying the
2546
wt.commit('B', rev_id='B-id', recursive=None)
2547
wt.set_last_revision('A-id')
2548
wt.branch.set_last_revision_info(1, 'A-id')
2549
wt.commit('C', rev_id='C-id', recursive=None)
2550
wt.merge_from_branch(wt.branch, to_revision='B-id')
2551
self.build_tree_contents([('tree/sub/file', 'text2')])
2552
sub_tree.commit('modify contents', rev_id='sub-B-id')
2553
wt.commit('E', rev_id='E-id', recursive=None)
2554
wt.set_parent_ids(['B-id', 'C-id'])
2555
wt.branch.set_last_revision_info(2, 'B-id')
2556
wt.commit('D', rev_id='D-id', recursive=None)
2558
merger = _mod_merge.Merger.from_revision_ids(progress.DummyProgress(),
2560
merger.merge_type = _mod_merge.Merge3Merger
2561
merge_obj = merger.make_merger()
2562
entries = list(merge_obj._entries_lca())
2563
# Nothing interesting about this sub-tree, because content changes are
2564
# computed at a higher level
2565
self.assertEqual([], entries)
2567
def test_nested_tree_subtree_renamed(self):
2568
# Tested with a real WT, because BranchBuilder/MemoryTree don't handle
2570
wt = self.make_branch_and_tree('tree',
2571
format='dirstate-with-subtree')
2573
self.addCleanup(wt.unlock)
2574
sub_tree = self.make_branch_and_tree('tree/sub',
2575
format='dirstate-with-subtree')
2576
wt.set_root_id('a-root-id')
2577
sub_tree.set_root_id('sub-tree-root')
2578
self.build_tree_contents([('tree/sub/file', 'text1')])
2579
sub_tree.add('file')
2580
sub_tree.commit('foo', rev_id='sub-A-id')
2581
wt.add_reference(sub_tree)
2582
wt.commit('set text to 1', rev_id='A-id', recursive=None)
2583
# Now create a criss-cross merge in the parent, without modifying the
2585
wt.commit('B', rev_id='B-id', recursive=None)
2586
wt.set_last_revision('A-id')
2587
wt.branch.set_last_revision_info(1, 'A-id')
2588
wt.commit('C', rev_id='C-id', recursive=None)
2589
wt.merge_from_branch(wt.branch, to_revision='B-id')
2590
wt.rename_one('sub', 'alt_sub')
2591
wt.commit('E', rev_id='E-id', recursive=None)
2592
wt.set_last_revision('B-id')
2594
wt.set_parent_ids(['B-id', 'C-id'])
2595
wt.branch.set_last_revision_info(2, 'B-id')
2596
wt.commit('D', rev_id='D-id', recursive=None)
2598
merger = _mod_merge.Merger.from_revision_ids(progress.DummyProgress(),
2600
merger.merge_type = _mod_merge.Merge3Merger
2601
merge_obj = merger.make_merger()
2602
entries = list(merge_obj._entries_lca())
2603
root_id = 'a-root-id'
2604
self.assertEqual([('sub-tree-root', False,
2605
((root_id, [root_id, root_id]), root_id, root_id),
2606
((u'sub', [u'sub', u'sub']), u'alt_sub', u'sub'),
2607
((False, [False, False]), False, False)),
2610
def test_nested_tree_subtree_renamed_and_modified(self):
2611
# Tested with a real WT, because BranchBuilder/MemoryTree don't handle
2613
wt = self.make_branch_and_tree('tree',
2614
format='dirstate-with-subtree')
2616
self.addCleanup(wt.unlock)
2617
sub_tree = self.make_branch_and_tree('tree/sub',
2618
format='dirstate-with-subtree')
2619
wt.set_root_id('a-root-id')
2620
sub_tree.set_root_id('sub-tree-root')
2621
self.build_tree_contents([('tree/sub/file', 'text1')])
2622
sub_tree.add('file')
2623
sub_tree.commit('foo', rev_id='sub-A-id')
2624
wt.add_reference(sub_tree)
2625
wt.commit('set text to 1', rev_id='A-id', recursive=None)
2626
# Now create a criss-cross merge in the parent, without modifying the
2628
wt.commit('B', rev_id='B-id', recursive=None)
2629
wt.set_last_revision('A-id')
2630
wt.branch.set_last_revision_info(1, 'A-id')
2631
wt.commit('C', rev_id='C-id', recursive=None)
2632
wt.merge_from_branch(wt.branch, to_revision='B-id')
2633
self.build_tree_contents([('tree/sub/file', 'text2')])
2634
sub_tree.commit('modify contents', rev_id='sub-B-id')
2635
wt.rename_one('sub', 'alt_sub')
2636
wt.commit('E', rev_id='E-id', recursive=None)
2637
wt.set_last_revision('B-id')
2639
wt.set_parent_ids(['B-id', 'C-id'])
2640
wt.branch.set_last_revision_info(2, 'B-id')
2641
wt.commit('D', rev_id='D-id', recursive=None)
2643
merger = _mod_merge.Merger.from_revision_ids(progress.DummyProgress(),
2645
merger.merge_type = _mod_merge.Merge3Merger
2646
merge_obj = merger.make_merger()
2647
entries = list(merge_obj._entries_lca())
2648
root_id = 'a-root-id'
2649
self.assertEqual([('sub-tree-root', False,
2650
((root_id, [root_id, root_id]), root_id, root_id),
2651
((u'sub', [u'sub', u'sub']), u'alt_sub', u'sub'),
2652
((False, [False, False]), False, False)),
2656
class TestLCAMultiWay(tests.TestCase):
2658
def assertLCAMultiWay(self, expected, base, lcas, other, this,
2659
allow_overriding_lca=True):
2660
self.assertEqual(expected, _mod_merge.Merge3Merger._lca_multi_way(
2661
(base, lcas), other, this,
2662
allow_overriding_lca=allow_overriding_lca))
2664
def test_other_equal_equal_lcas(self):
2665
"""Test when OTHER=LCA and all LCAs are identical."""
2666
self.assertLCAMultiWay('this',
2667
'bval', ['bval', 'bval'], 'bval', 'bval')
2668
self.assertLCAMultiWay('this',
2669
'bval', ['lcaval', 'lcaval'], 'lcaval', 'bval')
2670
self.assertLCAMultiWay('this',
2671
'bval', ['lcaval', 'lcaval', 'lcaval'], 'lcaval', 'bval')
2672
self.assertLCAMultiWay('this',
2673
'bval', ['lcaval', 'lcaval', 'lcaval'], 'lcaval', 'tval')
2674
self.assertLCAMultiWay('this',
2675
'bval', ['lcaval', 'lcaval', 'lcaval'], 'lcaval', None)
2677
def test_other_equal_this(self):
2678
"""Test when other and this are identical."""
2679
self.assertLCAMultiWay('this',
2680
'bval', ['bval', 'bval'], 'oval', 'oval')
2681
self.assertLCAMultiWay('this',
2682
'bval', ['lcaval', 'lcaval'], 'oval', 'oval')
2683
self.assertLCAMultiWay('this',
2684
'bval', ['cval', 'dval'], 'oval', 'oval')
2685
self.assertLCAMultiWay('this',
2686
'bval', [None, 'lcaval'], 'oval', 'oval')
2687
self.assertLCAMultiWay('this',
2688
None, [None, 'lcaval'], 'oval', 'oval')
2689
self.assertLCAMultiWay('this',
2690
None, ['lcaval', 'lcaval'], 'oval', 'oval')
2691
self.assertLCAMultiWay('this',
2692
None, ['cval', 'dval'], 'oval', 'oval')
2693
self.assertLCAMultiWay('this',
2694
None, ['cval', 'dval'], None, None)
2695
self.assertLCAMultiWay('this',
2696
None, ['cval', 'dval', 'eval', 'fval'], 'oval', 'oval')
2698
def test_no_lcas(self):
2699
self.assertLCAMultiWay('this',
2700
'bval', [], 'bval', 'tval')
2701
self.assertLCAMultiWay('other',
2702
'bval', [], 'oval', 'bval')
2703
self.assertLCAMultiWay('conflict',
2704
'bval', [], 'oval', 'tval')
2705
self.assertLCAMultiWay('this',
2706
'bval', [], 'oval', 'oval')
2708
def test_lca_supersedes_other_lca(self):
2709
"""If one lca == base, the other lca takes precedence"""
2710
self.assertLCAMultiWay('this',
2711
'bval', ['bval', 'lcaval'], 'lcaval', 'tval')
2712
self.assertLCAMultiWay('this',
2713
'bval', ['bval', 'lcaval'], 'lcaval', 'bval')
2714
# This is actually considered a 'revert' because the 'lcaval' in LCAS
2715
# supersedes the BASE val (in the other LCA) but then OTHER reverts it
2717
self.assertLCAMultiWay('other',
2718
'bval', ['bval', 'lcaval'], 'bval', 'lcaval')
2719
self.assertLCAMultiWay('conflict',
2720
'bval', ['bval', 'lcaval'], 'bval', 'tval')
2722
def test_other_and_this_pick_different_lca(self):
2723
# OTHER and THIS resolve the lca conflict in different ways
2724
self.assertLCAMultiWay('conflict',
2725
'bval', ['lca1val', 'lca2val'], 'lca1val', 'lca2val')
2726
self.assertLCAMultiWay('conflict',
2727
'bval', ['lca1val', 'lca2val', 'lca3val'], 'lca1val', 'lca2val')
2728
self.assertLCAMultiWay('conflict',
2729
'bval', ['lca1val', 'lca2val', 'bval'], 'lca1val', 'lca2val')
2731
def test_other_in_lca(self):
2732
# OTHER takes a value of one of the LCAs, THIS takes a new value, which
2733
# theoretically supersedes both LCA values and 'wins'
2734
self.assertLCAMultiWay('this',
2735
'bval', ['lca1val', 'lca2val'], 'lca1val', 'newval')
2736
self.assertLCAMultiWay('this',
2737
'bval', ['lca1val', 'lca2val', 'lca3val'], 'lca1val', 'newval')
2738
self.assertLCAMultiWay('conflict',
2739
'bval', ['lca1val', 'lca2val'], 'lca1val', 'newval',
2740
allow_overriding_lca=False)
2741
self.assertLCAMultiWay('conflict',
2742
'bval', ['lca1val', 'lca2val', 'lca3val'], 'lca1val', 'newval',
2743
allow_overriding_lca=False)
2744
# THIS reverted back to BASE, but that is an explicit supersede of all
2746
self.assertLCAMultiWay('this',
2747
'bval', ['lca1val', 'lca2val', 'lca3val'], 'lca1val', 'bval')
2748
self.assertLCAMultiWay('this',
2749
'bval', ['lca1val', 'lca2val', 'bval'], 'lca1val', 'bval')
2750
self.assertLCAMultiWay('conflict',
2751
'bval', ['lca1val', 'lca2val', 'lca3val'], 'lca1val', 'bval',
2752
allow_overriding_lca=False)
2753
self.assertLCAMultiWay('conflict',
2754
'bval', ['lca1val', 'lca2val', 'bval'], 'lca1val', 'bval',
2755
allow_overriding_lca=False)
2757
def test_this_in_lca(self):
2758
# THIS takes a value of one of the LCAs, OTHER takes a new value, which
2759
# theoretically supersedes both LCA values and 'wins'
2760
self.assertLCAMultiWay('other',
2761
'bval', ['lca1val', 'lca2val'], 'oval', 'lca1val')
2762
self.assertLCAMultiWay('other',
2763
'bval', ['lca1val', 'lca2val'], 'oval', 'lca2val')
2764
self.assertLCAMultiWay('conflict',
2765
'bval', ['lca1val', 'lca2val'], 'oval', 'lca1val',
2766
allow_overriding_lca=False)
2767
self.assertLCAMultiWay('conflict',
2768
'bval', ['lca1val', 'lca2val'], 'oval', 'lca2val',
2769
allow_overriding_lca=False)
2770
# OTHER reverted back to BASE, but that is an explicit supersede of all
2772
self.assertLCAMultiWay('other',
2773
'bval', ['lca1val', 'lca2val', 'lca3val'], 'bval', 'lca3val')
2774
self.assertLCAMultiWay('conflict',
2775
'bval', ['lca1val', 'lca2val', 'lca3val'], 'bval', 'lca3val',
2776
allow_overriding_lca=False)
2778
def test_all_differ(self):
2779
self.assertLCAMultiWay('conflict',
2780
'bval', ['lca1val', 'lca2val'], 'oval', 'tval')
2781
self.assertLCAMultiWay('conflict',
2782
'bval', ['lca1val', 'lca2val', 'lca2val'], 'oval', 'tval')
2783
self.assertLCAMultiWay('conflict',
2784
'bval', ['lca1val', 'lca2val', 'lca3val'], 'oval', 'tval')