24
27
from bzrlib.branch import Branch
25
28
from bzrlib.bzrdir import BzrDirMetaFormat1
26
29
from bzrlib.osutils import abspath
27
from bzrlib.repository import RepositoryFormatKnit1
30
from bzrlib.repofmt.knitrepo import RepositoryFormatKnit1
28
31
from bzrlib.tests.blackbox import ExternalBase
29
32
from bzrlib.uncommit import uncommit
30
33
from bzrlib.urlutils import local_path_from_url
160
163
t.add('filename', 'funky-chars<>%&;"\'')
161
164
t.commit('commit filename')
162
165
self.run_bzr('push', '../new-tree')
167
def create_simple_tree(self):
168
tree = self.make_branch_and_tree('tree')
169
self.build_tree(['tree/a'])
170
tree.add(['a'], ['a-id'])
171
tree.commit('one', rev_id='r1')
174
def test_push_create_prefix(self):
175
"""'bzr push --create-prefix' will create leading directories."""
176
tree = self.create_simple_tree()
178
self.run_bzr_error(['Parent directory of ../new/tree does not exist'],
179
'push', '../new/tree',
181
self.run_bzr('push', '../new/tree', '--create-prefix',
183
new_tree = WorkingTree.open('new/tree')
184
self.assertEqual(tree.last_revision(), new_tree.last_revision())
185
self.failUnlessExists('new/tree/a')
187
def test_push_use_existing(self):
188
"""'bzr push --use-existing-dir' can push into an existing dir.
190
By default, 'bzr push' will not use an existing, non-versioned dir.
192
tree = self.create_simple_tree()
193
self.build_tree(['target/'])
195
self.run_bzr_error(['Target directory ../target already exists',
196
'Supply --use-existing-dir',
197
], 'push', '../target',
200
self.run_bzr('push', '--use-existing-dir', '../target',
203
new_tree = WorkingTree.open('target')
204
self.assertEqual(tree.last_revision(), new_tree.last_revision())
205
# The push should have created target/a
206
self.failUnlessExists('target/a')
208
def test_push_onto_repo(self):
209
"""We should be able to 'bzr push' into an existing bzrdir."""
210
tree = self.create_simple_tree()
211
repo = self.make_repository('repo', shared=True)
213
self.run_bzr('push', '../repo',
216
# Pushing onto an existing bzrdir will create a repository and
217
# branch as needed, but will only create a working tree if there was
219
self.assertRaises(errors.NoWorkingTree, WorkingTree.open, 'repo')
220
new_branch = Branch.open('repo')
221
self.assertEqual(tree.last_revision(), new_branch.last_revision())
223
def test_push_onto_just_bzrdir(self):
224
"""We don't handle when the target is just a bzrdir.
226
Because you shouldn't be able to create *just* a bzrdir in the wild.
228
# TODO: jam 20070109 Maybe it would be better to create the repository
230
tree = self.create_simple_tree()
231
a_bzrdir = self.make_bzrdir('dir')
233
self.run_bzr_error(['At ../dir you have a valid .bzr control'],