159
159
self.build_tree(['a/b/'])
160
160
tree_a.add('b', 'b-id')
161
161
tree_a.commit('added b')
162
base_tree = tree_a.basis_tree()
162
# basis_tree() is only guaranteed to be valid as long as it is actually
163
# the basis tree. This mutates the tree after grabbing basis, so go to
165
base_tree = tree_a.branch.repository.revision_tree(tree_a.last_revision())
163
166
tree_z = tree_a.bzrdir.sprout('z').open_workingtree()
164
167
self.build_tree(['a/b/c'])
165
168
tree_a.add('b/c')
171
174
conflicts.MissingParent('Created directory', 'b', 'b-id'),
172
175
conflicts.UnversionedParent('Versioned directory', 'b', 'b-id')],
173
176
tree_z.conflicts())
174
merge_inner(tree_a.branch, tree_z.basis_tree(), base_tree,
177
merge_inner(tree_a.branch, tree_z.basis_tree(), base_tree,
175
178
this_tree=tree_a)
176
179
self.assertEqual([
177
180
conflicts.DeletingParent('Not deleting', 'b', 'b-id'),
178
181
conflicts.UnversionedParent('Versioned directory', 'b', 'b-id')],
179
182
tree_a.conflicts())
184
def test_nested_merge(self):
185
tree = self.make_branch_and_tree('tree',
186
format='dirstate-with-subtree')
187
sub_tree = self.make_branch_and_tree('tree/sub-tree',
188
format='dirstate-with-subtree')
189
sub_tree.set_root_id('sub-tree-root')
190
self.build_tree_contents([('tree/sub-tree/file', 'text1')])
192
sub_tree.commit('foo')
193
tree.add_reference(sub_tree)
194
tree.commit('set text to 1')
195
tree2 = tree.bzrdir.sprout('tree2').open_workingtree()
196
# modify the file in the subtree
197
self.build_tree_contents([('tree2/sub-tree/file', 'text2')])
198
# and merge the changes from the diverged subtree into the containing
200
tree2.commit('changed file text')
201
tree.merge_from_branch(tree2.branch)
202
self.assertFileEqual('text2', 'tree/sub-tree/file')
181
204
def test_merge_with_missing(self):
182
205
tree_a = self.make_branch_and_tree('tree_a')
183
206
self.build_tree_contents([('tree_a/file', 'content_1')])
184
207
tree_a.add('file')
185
208
tree_a.commit('commit base')
186
base_tree = tree_a.basis_tree()
209
# basis_tree() is only guaranteed to be valid as long as it is actually
210
# the basis tree. This mutates the tree after grabbing basis, so go to
212
base_tree = tree_a.branch.repository.revision_tree(tree_a.last_revision())
187
213
tree_b = tree_a.bzrdir.sprout('tree_b').open_workingtree()
188
214
self.build_tree_contents([('tree_a/file', 'content_2')])
189
215
tree_a.commit('commit other')