1281
1281
# LCA's all have the same last-modified revision for the file, as do
1282
1282
# the tips, but the base has something different
1283
1283
# A base, doesn't have the file
1285
1285
# B C B introduces 'foo', C introduces 'bar'
1287
1287
# D E D and E now both have 'foo' and 'bar'
1289
1289
# F G the files are now in F, G, D and E, but not in A
1290
1290
# G modifies 'bar'
1292
1292
builder = self.get_builder()
1293
1293
builder.build_snapshot('A-id', None,
1294
1294
[('add', (u'', 'a-root-id', 'directory', None))])
2249
2249
self.assertEqual(0, conflicts)
2250
2250
self.assertEqual('F content\n', wt.get_file_text('foo-id'))
2252
def test_all_wt(self):
2253
"""Check behavior if all trees are Working Trees."""
2254
# The big issue is that entry.revision is None for WorkingTrees. (as is
2255
# entry.text_sha1, etc. So we need to make sure we handle that case
2257
# A Content of 'foo', path of 'a'
2259
# B C B modifies content, C renames 'a' => 'b'
2261
# D E E updates content, renames 'b' => 'c'
2262
builder = self.get_builder()
2263
builder.build_snapshot('A-id', None,
2264
[('add', (u'', 'a-root-id', 'directory', None)),
2265
('add', (u'a', 'a-id', 'file', 'base content\n')),
2266
('add', (u'foo', 'foo-id', 'file', 'base content\n'))])
2267
builder.build_snapshot('B-id', ['A-id'],
2268
[('modify', ('foo-id', 'B content\n'))])
2269
builder.build_snapshot('C-id', ['A-id'],
2270
[('rename', ('a', 'b'))])
2271
builder.build_snapshot('E-id', ['C-id', 'B-id'],
2272
[('rename', ('b', 'c')),
2273
('modify', ('foo-id', 'E content\n'))])
2274
builder.build_snapshot('D-id', ['B-id', 'C-id'],
2275
[('rename', ('a', 'b'))]) # merged change
2276
wt_this = self.get_wt_from_builder(builder)
2277
wt_base = wt_this.bzrdir.sprout('base', 'A-id').open_workingtree()
2279
self.addCleanup(wt_base.unlock)
2280
wt_lca1 = wt_this.bzrdir.sprout('b-tree', 'B-id').open_workingtree()
2282
self.addCleanup(wt_lca1.unlock)
2283
wt_lca2 = wt_this.bzrdir.sprout('c-tree', 'C-id').open_workingtree()
2285
self.addCleanup(wt_lca2.unlock)
2286
wt_other = wt_this.bzrdir.sprout('other', 'E-id').open_workingtree()
2287
wt_other.lock_read()
2288
self.addCleanup(wt_other.unlock)
2289
merge_obj = _mod_merge.Merge3Merger(wt_this, wt_this, wt_base,
2290
wt_other, lca_trees=[wt_lca1, wt_lca2], do_merge=False)
2291
entries = list(merge_obj._entries_lca())
2292
root_id = 'a-root-id'
2293
self.assertEqual([('a-id', False,
2294
((root_id, [root_id, root_id]), root_id, root_id),
2295
((u'a', [u'a', u'b']), u'c', u'b'),
2296
((False, [False, False]), False, False)),
2298
((root_id, [root_id, root_id]), root_id, root_id),
2299
((u'foo', [u'foo', u'foo']), u'foo', u'foo'),
2300
((False, [False, False]), False, False)),
2253
2304
class TestLCAMultiWay(tests.TestCase):