160
162
t.add('filename', 'funky-chars<>%&;"\'')
161
163
t.commit('commit filename')
162
164
self.run_bzr('push', '../new-tree')
166
def test_push_dash_d(self):
167
t = self.make_branch_and_tree('from')
168
t.commit(allow_pointless=True,
169
message='first commit')
170
self.runbzr('push -d from to-one')
171
self.failUnlessExists('to-one')
172
self.runbzr('push -d %s %s'
173
% tuple(map(urlutils.local_path_to_url, ['from', 'to-two'])))
174
self.failUnlessExists('to-two')
176
def create_simple_tree(self):
177
tree = self.make_branch_and_tree('tree')
178
self.build_tree(['tree/a'])
179
tree.add(['a'], ['a-id'])
180
tree.commit('one', rev_id='r1')
183
def test_push_create_prefix(self):
184
"""'bzr push --create-prefix' will create leading directories."""
185
tree = self.create_simple_tree()
187
self.run_bzr_error(['Parent directory of ../new/tree does not exist'],
188
'push', '../new/tree',
190
self.run_bzr('push', '../new/tree', '--create-prefix',
192
new_tree = WorkingTree.open('new/tree')
193
self.assertEqual(tree.last_revision(), new_tree.last_revision())
194
self.failUnlessExists('new/tree/a')
196
def test_push_use_existing(self):
197
"""'bzr push --use-existing-dir' can push into an existing dir.
199
By default, 'bzr push' will not use an existing, non-versioned dir.
201
tree = self.create_simple_tree()
202
self.build_tree(['target/'])
204
self.run_bzr_error(['Target directory ../target already exists',
205
'Supply --use-existing-dir',
206
], 'push', '../target',
209
self.run_bzr('push', '--use-existing-dir', '../target',
212
new_tree = WorkingTree.open('target')
213
self.assertEqual(tree.last_revision(), new_tree.last_revision())
214
# The push should have created target/a
215
self.failUnlessExists('target/a')
217
def test_push_onto_repo(self):
218
"""We should be able to 'bzr push' into an existing bzrdir."""
219
tree = self.create_simple_tree()
220
repo = self.make_repository('repo', shared=True)
222
self.run_bzr('push', '../repo',
225
# Pushing onto an existing bzrdir will create a repository and
226
# branch as needed, but will only create a working tree if there was
228
self.assertRaises(errors.NoWorkingTree, WorkingTree.open, 'repo')
229
new_branch = Branch.open('repo')
230
self.assertEqual(tree.last_revision(), new_branch.last_revision())
232
def test_push_onto_just_bzrdir(self):
233
"""We don't handle when the target is just a bzrdir.
235
Because you shouldn't be able to create *just* a bzrdir in the wild.
237
# TODO: jam 20070109 Maybe it would be better to create the repository
239
tree = self.create_simple_tree()
240
a_bzrdir = self.make_bzrdir('dir')
242
self.run_bzr_error(['At ../dir you have a valid .bzr control'],