52
53
tree_b.commit('commit c')
53
54
# initial push location must be empty
54
55
self.assertEqual(None, branch_b.get_push_location())
55
57
# test push for failure without push location set
56
58
os.chdir('branch_a')
57
59
out = self.runbzr('push', retcode=3)
58
60
self.assertEquals(out,
59
61
('','bzr: ERROR: No push location known or specified.\n'))
63
# test not remembered if cannot actually push
64
self.run_bzr('push', '../path/which/doesnt/exist', retcode=3)
65
out = self.run_bzr('push', retcode=3)
67
('', 'bzr: ERROR: No push location known or specified.\n'),
60
70
# test implicit --remember when no push location set, push fails
61
out = self.runbzr('push ../branch_b', retcode=3)
71
out = self.run_bzr('push', '../branch_b', retcode=3)
62
72
self.assertEquals(out,
63
73
('','bzr: ERROR: These branches have diverged. '
64
74
'Try a merge then push with overwrite.\n'))
65
75
self.assertEquals(abspath(branch_a.get_push_location()),
66
76
abspath(branch_b.bzrdir.root_transport.base))
67
78
# test implicit --remember after resolving previous failure
68
79
uncommit(branch=branch_b, tree=tree_b)
69
80
transport.delete('branch_b/c')
71
self.assertEquals(abspath(branch_a.get_push_location()),
72
abspath(branch_b.bzrdir.root_transport.base))
81
out = self.run_bzr('push')
82
path = branch_a.get_push_location()
83
self.assertEquals(('Using saved location: %s\n'
84
% (local_path_from_url(path),)
85
, 'All changes applied successfully.\n'
86
'1 revision(s) pushed.\n'), out)
87
self.assertEqual(path,
88
branch_b.bzrdir.root_transport.base)
73
89
# test explicit --remember
74
self.runbzr('push ../branch_c --remember')
75
self.assertEquals(abspath(branch_a.get_push_location()),
76
abspath(branch_c.bzrdir.root_transport.base))
90
self.run_bzr('push', '../branch_c', '--remember')
91
self.assertEquals(branch_a.get_push_location(),
92
branch_c.bzrdir.root_transport.base)
78
94
def test_push_without_tree(self):
79
95
# bzr push from a branch that does not have a checkout should work.