1
1
# Copyright (C) 2005 by Canonical Ltd
2
2
# -*- coding: utf-8 -*-
4
4
# This program is free software; you can redistribute it and/or modify
5
5
# it under the terms of the GNU General Public License as published by
6
6
# the Free Software Foundation; either version 2 of the License, or
7
7
# (at your option) any later version.
9
9
# This program is distributed in the hope that it will be useful,
10
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
12
# GNU General Public License for more details.
14
14
# You should have received a copy of the GNU General Public License
15
15
# along with this program; if not, write to the Free Software
16
16
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
53
52
tree_b.commit('commit c')
54
53
# initial push location must be empty
55
54
self.assertEqual(None, branch_b.get_push_location())
57
55
# test push for failure without push location set
58
56
os.chdir('branch_a')
59
57
out = self.runbzr('push', retcode=3)
60
58
self.assertEquals(out,
61
59
('','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'),
70
60
# test implicit --remember when no push location set, push fails
71
out = self.run_bzr('push', '../branch_b', retcode=3)
61
out = self.runbzr('push ../branch_b', retcode=3)
72
62
self.assertEquals(out,
73
63
('','bzr: ERROR: These branches have diverged. '
74
64
'Try a merge then push with overwrite.\n'))
75
65
self.assertEquals(abspath(branch_a.get_push_location()),
76
66
abspath(branch_b.bzrdir.root_transport.base))
78
67
# test implicit --remember after resolving previous failure
79
68
uncommit(branch=branch_b, tree=tree_b)
80
69
transport.delete('branch_b/c')
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)
71
self.assertEquals(abspath(branch_a.get_push_location()),
72
abspath(branch_b.bzrdir.root_transport.base))
89
73
# test explicit --remember
90
self.run_bzr('push', '../branch_c', '--remember')
91
self.assertEquals(branch_a.get_push_location(),
92
branch_c.bzrdir.root_transport.base)
74
self.runbzr('push ../branch_c --remember')
75
self.assertEquals(abspath(branch_a.get_push_location()),
76
abspath(branch_c.bzrdir.root_transport.base))
94
78
def test_push_without_tree(self):
95
79
# bzr push from a branch that does not have a checkout should work.
153
137
self.assertFalse(pushed_repo.has_revision('a-2'))
154
138
self.assertTrue(pushed_repo.has_revision('b-1'))
156
def test_push_funky_id(self):
157
t = self.make_branch_and_tree('tree')
159
self.build_tree(['filename'])
160
t.add('filename', 'funky-chars<>%&;"\'')
161
t.commit('commit filename')
162
self.run_bzr('push', '../new-tree')