29
29
from bzrlib.bzrdir import BzrDirMetaFormat1
30
30
from bzrlib.osutils import abspath
31
31
from bzrlib.repofmt.knitrepo import RepositoryFormatKnit1
32
from bzrlib.smart import client, server
32
33
from bzrlib.tests.blackbox import ExternalBase
33
34
from bzrlib.tests.http_server import HttpServer
34
35
from bzrlib.transport.memory import MemoryServer, MemoryTransport
40
41
class TestPush(ExternalBase):
43
def test_push_error_on_vfs_http(self):
44
""" pushing a branch to a HTTP server fails cleanly. """
45
# the trunk is published on a web server
46
self.transport_readonly_server = HttpServer
47
self.make_branch('source')
48
public_url = self.get_readonly_url('target')
49
self.run_bzr_error(['http does not support mkdir'],
42
53
def test_push_remember(self):
43
54
"""Push changes from one branch to another and test push location."""
44
55
transport = self.get_transport()
98
109
self.run_bzr('push ../branch_c --remember')
99
110
self.assertEquals(branch_a.get_push_location(),
100
111
branch_c.bzrdir.root_transport.base)
102
113
def test_push_without_tree(self):
103
114
# bzr push from a branch that does not have a checkout should work.
104
115
b = self.make_branch('.')
109
120
self.assertEndsWith(b2.base, 'pushed-location/')
111
122
def test_push_new_branch_revision_count(self):
112
# bzr push of a branch with revisions to a new location
113
# should print the number of revisions equal to the length of the
123
# bzr push of a branch with revisions to a new location
124
# should print the number of revisions equal to the length of the
115
126
t = self.make_branch_and_tree('tree')
116
127
self.build_tree(['tree/file'])
175
186
message='first commit')
176
187
self.run_bzr('push -d from to-one')
177
188
self.failUnlessExists('to-one')
178
self.run_bzr('push -d %s %s'
189
self.run_bzr('push -d %s %s'
179
190
% tuple(map(urlutils.local_path_to_url, ['from', 'to-two'])))
180
191
self.failUnlessExists('to-two')
193
def test_push_smart_non_stacked_streaming_acceptance(self):
194
self.setup_smart_server_with_call_log()
195
t = self.make_branch_and_tree('from')
196
t.commit(allow_pointless=True, message='first commit')
197
self.reset_smart_call_log()
198
self.run_bzr(['push', self.get_url('to-one')], working_dir='from')
199
rpc_count = len(self.hpss_calls)
200
# This figure represent the amount of work to perform this use case. It
201
# is entirely ok to reduce this number if a test fails due to rpc_count
202
# being too low. If rpc_count increases, more network roundtrips have
203
# become necessary for this use case. Please do not adjust this number
204
# upwards without agreement from bzr's network support maintainers.
205
self.assertEqual(27, rpc_count)
207
def test_push_smart_stacked_streaming_acceptance(self):
208
self.setup_smart_server_with_call_log()
209
parent = self.make_branch_and_tree('parent', format='1.9')
210
parent.commit(message='first commit')
211
local = parent.bzrdir.sprout('local').open_workingtree()
212
local.commit(message='local commit')
213
self.reset_smart_call_log()
214
self.run_bzr(['push', '--stacked', '--stacked-on', '../parent',
215
self.get_url('public')], working_dir='local')
216
rpc_count = len(self.hpss_calls)
217
# This figure represent the amount of work to perform this use case. It
218
# is entirely ok to reduce this number if a test fails due to rpc_count
219
# being too low. If rpc_count increases, more network roundtrips have
220
# become necessary for this use case. Please do not adjust this number
221
# upwards without agreement from bzr's network support maintainers.
222
self.assertEqual(54, rpc_count)
223
remote = Branch.open('public')
224
self.assertEndsWith(remote.get_stacked_on_url(), '/parent')
182
226
def create_simple_tree(self):
183
227
tree = self.make_branch_and_tree('tree')
184
228
self.build_tree(['tree/a'])