256
259
entries = list(_tree_to_objects(revtree, [], self.idmap, {}))
257
260
self.assertEqual(['foo', ''], [p[0] for p in entries])
262
def test_merge(self):
263
basis_tree = self.make_branch_and_tree('base')
264
self.build_tree(['base/foo/'])
265
basis_tree.add(['foo'])
266
basis_rev = basis_tree.commit('foo')
267
basis_revtree = basis_tree.branch.repository.revision_tree(basis_rev)
269
tree_a = self.make_branch_and_tree('a')
270
tree_a.pull(basis_tree.branch)
272
self.build_tree(['a/foo/file1'])
273
self.build_tree(['a/foo/subdir-a/'])
274
os.symlink('.', 'a/foo/subdir-a/symlink')
275
tree_a.add(['foo/subdir-a', 'foo/subdir-a/symlink'])
277
tree_a.add(['foo/file1'])
278
rev_a = tree_a.commit('commit a')
279
revtree_a = tree_a.branch.repository.revision_tree(rev_a)
281
with revtree_a.lock_read():
282
entries = list(_tree_to_objects(revtree_a, [basis_revtree],
284
objects = {path: obj for (path, obj, key) in entries}
285
subdir_a = objects['foo/subdir-a']
287
tree_b = self.make_branch_and_tree('b')
288
tree_b.pull(basis_tree.branch)
289
self.build_tree(['b/foo/subdir/'])
290
os.symlink('.', 'b/foo/subdir/symlink')
291
tree_b.add(['foo/subdir', 'foo/subdir/symlink'])
292
rev_b = tree_b.commit('commit b')
293
revtree_b = tree_b.branch.repository.revision_tree(rev_b)
294
self.addCleanup(revtree_b.lock_read().unlock)
296
with revtree_b.lock_read():
297
list(_tree_to_objects(revtree_b, [basis_revtree], self.idmap, {}))
299
with tree_a.lock_write():
300
tree_a.merge_from_branch(tree_b.branch)
301
rev_merge = tree_a.commit('merge')
303
revtree_merge = tree_a.branch.basis_tree()
304
self.addCleanup(revtree_merge.lock_read().unlock)
306
entries = list(_tree_to_objects(
308
[tree_a.branch.repository.revision_tree(r)
309
for r in revtree_merge.get_parent_ids()],
311
objects = {path: obj for (path, obj, key) in entries}
312
self.assertEqual(set(['', 'foo', 'foo/subdir']), set(objects))
314
(stat.S_IFDIR, subdir_a.id), objects['foo'][b'subdir-a'])
260
317
class DirectoryToTreeTests(TestCase):