16
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
"""Black-box tests for bzr pull.
19
"""Black-box tests for bzr pull."""
25
24
from bzrlib.branch import Branch
25
from bzrlib.osutils import abspath
26
26
from bzrlib.tests.blackbox import ExternalBase
27
from bzrlib.uncommit import uncommit
28
30
class TestPull(ExternalBase):
46
48
self.runbzr('missing', retcode=3)
47
49
self.runbzr('missing .')
48
50
self.runbzr('missing')
49
if sys.platform not in ('win32', 'cygwin'):
50
# This is equivalent to doing "bzr pull ."
51
# Which means that bzr creates 2 branches grabbing
52
# the same location, and tries to pull.
53
# However, 2 branches mean 2 locks on the same file
54
# which ultimately implies a deadlock.
55
# (non windows platforms allow multiple locks on the
56
# same file by the same calling process)
51
# this will work on windows because we check for the same branch
52
# in pull - if it fails, it is a regression
58
54
self.runbzr('pull /', retcode=3)
59
55
if sys.platform not in ('win32', 'cygwin'):
60
56
self.runbzr('pull')
223
219
self.assertEqual(rev_history_b, rev_history_a)
221
def test_pull_remember(self):
222
"""Pull changes from one branch to another and test parent location."""
223
transport = self.get_transport()
224
tree_a = self.make_branch_and_tree('branch_a')
225
branch_a = tree_a.branch
226
self.build_tree(['branch_a/a'])
228
tree_a.commit('commit a')
229
tree_b = branch_a.bzrdir.sprout('branch_b').open_workingtree()
230
branch_b = tree_b.branch
231
tree_c = branch_a.bzrdir.sprout('branch_c').open_workingtree()
232
branch_c = tree_c.branch
233
self.build_tree(['branch_a/b'])
235
tree_a.commit('commit b')
237
parent = branch_b.get_parent()
238
branch_b.set_parent(None)
239
self.assertEqual(None, branch_b.get_parent())
240
# test pull for failure without parent set
242
out = self.runbzr('pull', retcode=3)
243
self.assertEquals(out,
244
('','bzr: ERROR: No pull location known or specified.\n'))
245
# test implicit --remember when no parent set, this pull conflicts
246
self.build_tree(['d'])
248
tree_b.commit('commit d')
249
out = self.runbzr('pull ../branch_a', retcode=3)
250
self.assertEquals(out,
251
('','bzr: ERROR: These branches have diverged. Try merge.\n'))
252
self.assertEquals(abspath(branch_b.get_parent()), abspath(parent))
253
# test implicit --remember after resolving previous failure
254
uncommit(branch=branch_b, tree=tree_b)
255
transport.delete('branch_b/d')
257
self.assertEquals(abspath(branch_b.get_parent()), abspath(parent))
258
# test explicit --remember
259
self.runbzr('pull ../branch_c --remember')
260
self.assertEquals(abspath(branch_b.get_parent()),
261
abspath(branch_c.bzrdir.root_transport.base))