247
247
tree_b.commit('commit d')
248
248
out = self.runbzr('pull ../branch_a', retcode=3)
249
249
self.assertEquals(out,
250
('','bzr: ERROR: These branches have diverged. Try merge.\n'))
250
('','bzr: ERROR: These branches have diverged. Use the merge command to reconcile them.\n'))
251
251
self.assertEquals(branch_b.get_parent(), parent)
252
252
# test implicit --remember after resolving previous failure
253
253
uncommit(branch=branch_b, tree=tree_b)
258
258
self.runbzr('pull ../branch_c --remember')
259
259
self.assertEquals(branch_b.get_parent(),
260
260
branch_c.bzrdir.root_transport.base)
262
def test_pull_bundle(self):
263
from bzrlib.testament import Testament
264
# Build up 2 trees and prepare for a pull
265
tree_a = self.make_branch_and_tree('branch_a')
266
f = open('branch_a/a', 'wb')
270
tree_a.commit('message')
272
tree_b = tree_a.bzrdir.sprout('branch_b').open_workingtree()
274
# Make a change to 'a' that 'b' can pull
275
f = open('branch_a/a', 'wb')
278
tree_a.commit('message')
280
# Create the bundle for 'b' to pull
282
bundle_file = open('../bundle', 'wb')
283
bundle_file.write(self.run_bzr('bundle', '../branch_b')[0])
286
os.chdir('../branch_b')
287
output = self.run_bzr('pull', '../bundle')
288
self.assertEqual('', output[0])
289
self.assertEqual('All changes applied successfully.\n'
290
'1 revision(s) pulled.\n', output[1])
292
self.assertEqualDiff(tree_a.branch.revision_history(),
293
tree_b.branch.revision_history())
295
testament_a = Testament.from_revision(tree_a.branch.repository,
296
tree_a.last_revision())
297
testament_b = Testament.from_revision(tree_b.branch.repository,
298
tree_b.last_revision())
299
self.assertEqualDiff(testament_a.as_text(),
300
testament_b.as_text())
302
# it is legal to attempt to pull an already-merged bundle
303
output = self.run_bzr('pull', '../bundle')
304
self.assertEqual('', output[0])
305
self.assertEqual('0 revision(s) pulled.\n', output[1])