~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2011-04-19 04:37:48 UTC
  • mfrom: (5741.3.8 506265-command-deprecation)
  • Revision ID: pqm@pqm.ubuntu.com-20110419043748-qq4lsmc50cckqzp7
(mbp) Deprecate 'bzr clone' and 'bzr get' (bug 506265) (Martin Pool)

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
 
23
23
from bzrlib import osutils
24
24
from bzrlib.workingtree import WorkingTree
25
 
from bzrlib.tests.blackbox import ExternalBase
 
25
from bzrlib.tests import TestCaseWithTransport
26
26
from bzrlib.directory_service import directories
27
27
 
28
28
 
29
 
class TestSwitch(ExternalBase):
 
29
class TestSwitch(TestCaseWithTransport):
30
30
 
31
31
    def _create_sample_tree(self):
32
32
        tree = self.make_branch_and_tree('branch-1')
149
149
        tree = self._create_sample_tree()
150
150
        checkout = tree.branch.create_checkout('checkout', lightweight=True)
151
151
        self.run_bzr(['switch', 'branch-1', '-r1'], working_dir='checkout')
152
 
        self.failUnlessExists('checkout/file-1')
153
 
        self.failIfExists('checkout/file-2')
 
152
        self.assertPathExists('checkout/file-1')
 
153
        self.assertPathDoesNotExist('checkout/file-2')
154
154
 
155
155
    def test_switch_only_revision(self):
156
156
        tree = self._create_sample_tree()
157
157
        checkout = tree.branch.create_checkout('checkout', lightweight=True)
158
 
        self.failUnlessExists('checkout/file-1')
159
 
        self.failUnlessExists('checkout/file-2')
 
158
        self.assertPathExists('checkout/file-1')
 
159
        self.assertPathExists('checkout/file-2')
160
160
        self.run_bzr(['switch', '-r1'], working_dir='checkout')
161
 
        self.failUnlessExists('checkout/file-1')
162
 
        self.failIfExists('checkout/file-2')
 
161
        self.assertPathExists('checkout/file-1')
 
162
        self.assertPathDoesNotExist('checkout/file-2')
163
163
        # Check that we don't accept a range
164
164
        self.run_bzr_error(
165
165
            ['bzr switch --revision takes exactly one revision identifier'],
252
252
        self.assertLength(0, calls)
253
253
        out, err = self.run_bzr('switch ../branch2')
254
254
        self.assertLength(1, calls)
 
255
 
 
256
    def test_switch_lightweight_directory(self):
 
257
        """Test --directory option"""
 
258
 
 
259
        # create a source branch
 
260
        a_tree = self.make_branch_and_tree('a')
 
261
        self.build_tree_contents([('a/a', 'initial\n')])
 
262
        a_tree.add('a')
 
263
        a_tree.commit(message='initial')
 
264
 
 
265
        # clone and add a differing revision
 
266
        b_tree = a_tree.bzrdir.sprout('b').open_workingtree()
 
267
        self.build_tree_contents([('b/a', 'initial\nmore\n')])
 
268
        b_tree.commit(message='more')
 
269
 
 
270
        self.run_bzr('checkout --lightweight a checkout')
 
271
        self.run_bzr('switch --directory checkout b')
 
272
        self.assertFileEqual('initial\nmore\n', 'checkout/a')