137
137
with merger.make_preview_transform() as tt:
138
138
self.assertEqual([], tt.find_conflicts())
139
139
preview = tt.get_preview_tree()
140
self.assertEqual(wt.get_root_id(), preview.get_root_id())
140
self.assertEqual(wt.path2id(''), preview.path2id(''))
142
142
def test_merge_unrelated_retains_root(self):
143
143
wt = self.make_branch_and_tree('tree')
149
149
with transform.TransformPreview(wt) as merger.tt:
150
150
merger._compute_transform()
151
151
new_root_id = merger.tt.final_file_id(merger.tt.root)
152
self.assertEqual(wt.get_root_id(), new_root_id)
152
self.assertEqual(wt.path2id(''), new_root_id)
154
154
def test_create_rename(self):
155
155
"""Rename an inventory entry while creating the file"""
511
511
self.build_tree(['a'])
513
513
first_rev = tree.commit("added a")
514
old_root_id = tree.get_root_id()
514
old_root_id = tree.path2id('')
515
515
merger = _mod_merge.Merger.from_revision_ids(tree,
516
516
_mod_revision.NULL_REVISION,
3179
3179
:param merge_as: the path in a tree to add the new directory as.
3180
3180
:returns: the conflicts from 'do_merge'.
3182
operation = cleanup.OperationWithCleanups(self._merge_into)
3183
return operation.run(location, merge_as)
3185
def _merge_into(self, op, location, merge_as):
3186
# Open and lock the various tree and branch objects
3187
wt, subdir_relpath = WorkingTree.open_containing(merge_as)
3188
op.add_cleanup(wt.lock_write().unlock)
3189
branch_to_merge, subdir_to_merge = _mod_branch.Branch.open_containing(
3191
op.add_cleanup(branch_to_merge.lock_read().unlock)
3192
other_tree = branch_to_merge.basis_tree()
3193
op.add_cleanup(other_tree.lock_read().unlock)
3195
merger = _mod_merge.MergeIntoMerger(
3196
this_tree=wt, other_tree=other_tree, other_branch=branch_to_merge,
3197
target_subdir=subdir_relpath, source_subpath=subdir_to_merge)
3198
merger.set_base_revision(_mod_revision.NULL_REVISION, branch_to_merge)
3199
conflicts = merger.do_merge()
3200
merger.set_pending()
3182
with cleanup.ExitStack() as stack:
3183
# Open and lock the various tree and branch objects
3184
wt, subdir_relpath = WorkingTree.open_containing(merge_as)
3185
stack.enter_context(wt.lock_write())
3186
branch_to_merge, subdir_to_merge = _mod_branch.Branch.open_containing(
3188
stack.enter_context(branch_to_merge.lock_read())
3189
other_tree = branch_to_merge.basis_tree()
3190
stack.enter_context(other_tree.lock_read())
3192
merger = _mod_merge.MergeIntoMerger(
3193
this_tree=wt, other_tree=other_tree, other_branch=branch_to_merge,
3194
target_subdir=subdir_relpath, source_subpath=subdir_to_merge)
3195
merger.set_base_revision(_mod_revision.NULL_REVISION, branch_to_merge)
3196
conflicts = merger.do_merge()
3197
merger.set_pending()
3203
3200
def assertTreeEntriesEqual(self, expected_entries, tree):
3204
3201
"""Assert that 'tree' contains the expected inventory entries.