1
# Copyright (C) 2005, 2006 Canonical Ltd
1
# Copyright (C) 2005 by Canonical Ltd
2
# -*- coding: utf-8 -*-
3
4
# This program is free software; you can redistribute it and/or modify
4
5
# it under the terms of the GNU General Public License as published by
23
24
from bzrlib.branch import Branch
24
25
from bzrlib.tests.blackbox import ExternalBase
25
26
from bzrlib.uncommit import uncommit
26
from bzrlib import urlutils
29
29
class TestPull(ExternalBase):
96
96
self.runbzr('pull ../b')
97
97
self.runbzr('pull ../b')
99
def test_pull_dash_d(self):
102
self.example_branch()
103
self.runbzr('init ../b')
104
self.runbzr('init ../c')
105
# pull into that branch
106
self.runbzr('pull -d ../b .')
107
# pull into a branch specified by a url
108
c_url = urlutils.local_path_to_url('../c')
109
self.assertStartsWith(c_url, 'file://')
110
self.runbzr('pull -d %s .' % c_url)
112
99
def test_pull_revision(self):
113
100
"""Pull some changes from one branch to another."""
260
247
tree_b.commit('commit d')
261
248
out = self.runbzr('pull ../branch_a', retcode=3)
262
249
self.assertEquals(out,
263
('','bzr: ERROR: These branches have diverged.'
264
' Use the merge command to reconcile them.\n'))
250
('','bzr: ERROR: These branches have diverged. Use the merge command to reconcile them.\n'))
265
251
self.assertEquals(branch_b.get_parent(), parent)
266
252
# test implicit --remember after resolving previous failure
267
253
uncommit(branch=branch_b, tree=tree_b)
298
284
bundle_file.close()
300
286
os.chdir('../branch_b')
301
out, err = self.run_bzr('pull', '../bundle')
302
self.assertEqual(out,
303
'Now on revision 2.\n')
304
self.assertEqual(err,
305
' M a\nAll changes applied successfully.\n')
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])
307
292
self.assertEqualDiff(tree_a.branch.revision_history(),
308
293
tree_b.branch.revision_history())
310
testament_a = Testament.from_revision(tree_a.branch.repository,
311
tree_a.get_parent_ids()[0])
295
testament_a = Testament.from_revision(tree_a.branch.repository,
296
tree_a.last_revision())
312
297
testament_b = Testament.from_revision(tree_b.branch.repository,
313
tree_b.get_parent_ids()[0])
298
tree_b.last_revision())
314
299
self.assertEqualDiff(testament_a.as_text(),
315
300
testament_b.as_text())
317
302
# it is legal to attempt to pull an already-merged bundle
318
out, err = self.run_bzr('pull', '../bundle')
319
self.assertEqual(err, '')
320
self.assertEqual(out, 'No revisions to pull.\n')
303
output = self.run_bzr('pull', '../bundle')
304
self.assertEqual('', output[0])
305
self.assertEqual('0 revision(s) pulled.\n', output[1])