25
25
from bzrlib.branch import Branch
26
from bzrlib.osutils import abspath
26
27
from bzrlib.tests.blackbox import ExternalBase
28
from bzrlib.uncommit import uncommit
28
31
class TestPull(ExternalBase):
223
226
self.assertEqual(rev_history_b, rev_history_a)
228
def test_pull_remember(self):
229
"""Pull changes from one branch to another and test parent location."""
230
transport = self.get_transport()
231
tree_a = self.make_branch_and_tree('branch_a')
232
branch_a = tree_a.branch
233
self.build_tree(['branch_a/a'])
235
tree_a.commit('commit a')
236
branch_b = branch_a.bzrdir.sprout('branch_b').open_branch()
237
tree_b = branch_b.bzrdir.open_workingtree()
238
branch_c = branch_a.bzrdir.sprout('branch_c').open_branch()
239
tree_c = branch_c.bzrdir.open_workingtree()
240
self.build_tree(['branch_a/b'])
242
tree_a.commit('commit b')
244
parent = branch_b.get_parent()
245
branch_b.set_parent(None)
246
self.assertEqual(None, branch_b.get_parent())
247
# test pull for failure without parent set
249
out = self.runbzr('pull', retcode=3)
250
self.assertEquals(out,
251
('','bzr: ERROR: No pull location known or specified.\n'))
252
# test implicit --remember when no parent set, this pull conflicts
253
self.build_tree(['d'])
255
tree_b.commit('commit d')
256
out = self.runbzr('pull ../branch_a', retcode=3)
257
self.assertEquals(out,
258
('','bzr: ERROR: These branches have diverged. Try merge.\n'))
259
self.assertEquals(abspath(branch_b.get_parent()), abspath(parent))
260
# test implicit --remember after resolving previous failure
261
uncommit(branch=branch_b, tree=tree_b)
262
transport.delete('branch_b/d')
264
self.assertEquals(abspath(branch_b.get_parent()), abspath(parent))
265
# test explicit --remember
266
self.runbzr('pull ../branch_c --remember')
267
self.assertEquals(abspath(branch_b.get_parent()),
268
abspath(branch_c.bzrdir.root_transport.base))