/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_push.py

  • Committer: John Arbash Meinel
  • Date: 2007-02-13 20:33:57 UTC
  • mfrom: (2283 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2294.
  • Revision ID: john@arbash-meinel.com-20070213203357-b7yg41mi9sk6cqd0
[merge] bzr.dev 2283
resolve conflicts in moved repository formats
small issue with osutils.contains_whitespace()

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
import os
22
22
 
 
23
from bzrlib import (
 
24
    errors,
 
25
    )
23
26
import bzrlib
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')
 
166
 
 
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')
 
172
        return tree
 
173
 
 
174
    def test_push_create_prefix(self):
 
175
        """'bzr push --create-prefix' will create leading directories."""
 
176
        tree = self.create_simple_tree()
 
177
 
 
178
        self.run_bzr_error(['Parent directory of ../new/tree does not exist'],
 
179
                           'push', '../new/tree',
 
180
                           working_dir='tree')
 
181
        self.run_bzr('push', '../new/tree', '--create-prefix',
 
182
                     working_dir='tree')
 
183
        new_tree = WorkingTree.open('new/tree')
 
184
        self.assertEqual(tree.last_revision(), new_tree.last_revision())
 
185
        self.failUnlessExists('new/tree/a')
 
186
 
 
187
    def test_push_use_existing(self):
 
188
        """'bzr push --use-existing-dir' can push into an existing dir.
 
189
 
 
190
        By default, 'bzr push' will not use an existing, non-versioned dir.
 
191
        """
 
192
        tree = self.create_simple_tree()
 
193
        self.build_tree(['target/'])
 
194
 
 
195
        self.run_bzr_error(['Target directory ../target already exists',
 
196
                            'Supply --use-existing-dir',
 
197
                           ], 'push', '../target',
 
198
                           working_dir='tree')
 
199
 
 
200
        self.run_bzr('push', '--use-existing-dir', '../target',
 
201
                     working_dir='tree')
 
202
 
 
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')
 
207
 
 
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)
 
212
 
 
213
        self.run_bzr('push', '../repo',
 
214
                     working_dir='tree')
 
215
 
 
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
 
218
        # no BzrDir before.
 
219
        self.assertRaises(errors.NoWorkingTree, WorkingTree.open, 'repo')
 
220
        new_branch = Branch.open('repo')
 
221
        self.assertEqual(tree.last_revision(), new_branch.last_revision())
 
222
 
 
223
    def test_push_onto_just_bzrdir(self):
 
224
        """We don't handle when the target is just a bzrdir.
 
225
 
 
226
        Because you shouldn't be able to create *just* a bzrdir in the wild.
 
227
        """
 
228
        # TODO: jam 20070109 Maybe it would be better to create the repository
 
229
        #       if at this point
 
230
        tree = self.create_simple_tree()
 
231
        a_bzrdir = self.make_bzrdir('dir')
 
232
 
 
233
        self.run_bzr_error(['At ../dir you have a valid .bzr control'],
 
234
                'push', '../dir',
 
235
                working_dir='tree')