28
28
class TestSwitch(ExternalBase):
30
def _create_sample_tree(self):
31
tree = self.make_branch_and_tree('branch-1')
32
self.build_tree(['branch-1/file-1', 'branch-1/file-2'])
30
39
def test_switch_up_to_date_light_checkout(self):
31
40
self.make_branch_and_tree('branch')
32
41
self.run_bzr('branch branch branch2')
135
144
self.assertEqual(branchb_id, checkout.last_revision())
136
145
self.assertEqual(tree2.branch.base, checkout.branch.get_bound_location())
147
def test_switch_revision(self):
148
tree = self._create_sample_tree()
149
checkout = tree.branch.create_checkout('checkout', lightweight=True)
150
self.run_bzr(['switch', 'branch-1', '-r1'], working_dir='checkout')
151
self.failUnlessExists('checkout/file-1')
152
self.failIfExists('checkout/file-2')
154
def test_switch_only_revision(self):
155
tree = self._create_sample_tree()
156
checkout = tree.branch.create_checkout('checkout', lightweight=True)
157
self.failUnlessExists('checkout/file-1')
158
self.failUnlessExists('checkout/file-2')
159
self.run_bzr(['switch', '-r1'], working_dir='checkout')
160
self.failUnlessExists('checkout/file-1')
161
self.failIfExists('checkout/file-2')
162
# Check that we don't accept a range
164
['bzr switch --revision takes exactly one revision identifier'],
165
['switch', '-r0..2'], working_dir='checkout')
138
167
def prepare_lightweight_switch(self):
139
168
branch = self.make_branch('branch')
140
169
branch.create_checkout('tree', lightweight=True)