136
136
self.failUnlessExists('sub/a.txt.BASE')
138
138
def test_merge_remember(self):
139
"""Merge changes from one branch to another and test parent location."""
139
"""Merge changes from one branch to another, test submit location."""
140
140
tree_a = self.make_branch_and_tree('branch_a')
141
141
branch_a = tree_a.branch
142
142
self.build_tree(['branch_a/a'])
167
167
self.run_bzr_error(['Working tree ".*" has uncommitted changes'],
168
168
'merge ../branch_a')
169
self.assertEquals(abspath(branch_b.get_parent()), abspath(parent))
169
self.assertEquals(abspath(branch_b.get_submit_branch()),
170
171
# test implicit --remember after resolving conflict
171
172
tree_b.commit('commit d')
172
173
out, err = self.run_bzr('merge')
174
175
base = urlutils.local_path_from_url(branch_a.base)
175
self.assertEquals(out, 'Merging from remembered location %s\n' % (base,))
176
self.assertEquals(out,
177
'Merging from remembered location %s\n' % (base,))
176
178
self.assertEquals(err, '+N b\nAll changes applied successfully.\n')
177
self.assertEquals(abspath(branch_b.get_parent()), abspath(parent))
179
self.assertEquals(abspath(branch_b.get_submit_branch()),
178
181
# re-open tree as external run_bzr modified it
179
182
tree_b = branch_b.bzrdir.open_workingtree()
180
183
tree_b.commit('merge branch_a')
182
185
out, err = self.run_bzr('merge ../branch_c --remember')
183
186
self.assertEquals(out, '')
184
187
self.assertEquals(err, '+N c\nAll changes applied successfully.\n')
185
self.assertEquals(abspath(branch_b.get_parent()),
188
self.assertEquals(abspath(branch_b.get_submit_branch()),
186
189
abspath(branch_c.bzrdir.root_transport.base))
187
190
# re-open tree as external run_bzr modified it
188
191
tree_b = branch_b.bzrdir.open_workingtree()
407
410
graph = tree_a.branch.repository.get_graph(tree_b.branch.repository)
408
411
out, err = self.run_bzr(['merge', '-d', 'a', 'b'])
409
412
self.assertContainsRe(err, 'Warning: criss-cross merge encountered.')
414
def test_merge_from_submit(self):
415
tree_a = self.make_branch_and_tree('a')
416
tree_b = tree_a.bzrdir.sprout('b').open_workingtree()
417
tree_c = tree_a.bzrdir.sprout('c').open_workingtree()
418
out, err = self.run_bzr(['merge', '-d', 'c'])
419
self.assertContainsRe(out, 'Merging from remembered location .*a\/$')
420
tree_c.branch.set_submit_branch(tree_b.bzrdir.root_transport.base)
421
out, err = self.run_bzr(['merge', '-d', 'c'])
422
self.assertContainsRe(out, 'Merging from remembered location .*b\/$')
424
def test_remember_sets_submit(self):
425
tree_a = self.make_branch_and_tree('a')
426
tree_b = tree_a.bzrdir.sprout('b').open_workingtree()
427
self.assertIs(tree_b.branch.get_submit_branch(), None)
429
# Remember should not happen if using default from parent
430
out, err = self.run_bzr(['merge', '-d', 'b'])
431
self.assertIs(tree_b.branch.get_submit_branch(), None)
433
# Remember should happen if user supplies location
434
out, err = self.run_bzr(['merge', '-d', 'b', 'a'])
435
self.assertEqual(tree_b.branch.get_submit_branch(),
436
tree_a.bzrdir.root_transport.base)