299
299
def test_switch_lightweight_after_branch_moved(self):
300
300
self.prepare_lightweight_switch()
301
self.run_bzr('switch --force --with-changes ../branch1',
301
self.run_bzr('switch --force ../branch1', working_dir='tree')
303
302
branch_location = WorkingTree.open('tree').branch.base
304
303
self.assertEndsWith(branch_location, 'branch1/')
306
305
def test_switch_lightweight_after_branch_moved_relative(self):
307
306
self.prepare_lightweight_switch()
308
self.run_bzr('switch --force branch1 --with-changes',
307
self.run_bzr('switch --force branch1', working_dir='tree')
310
308
branch_location = WorkingTree.open('tree').branch.base
311
309
self.assertEndsWith(branch_location, 'branch1/')
485
483
out, err = self.run_bzr(['checkout', '--lightweight', self.get_url('from'),
487
485
self.reset_smart_call_log()
488
self.run_bzr(['switch', '--with-changes',
489
self.get_url('from')], working_dir='target')
486
self.run_bzr(['switch', self.get_url('from')], working_dir='target')
490
487
# This figure represent the amount of work to perform this use case. It
491
488
# is entirely ok to reduce this number if a test fails due to rpc_count
492
489
# being too low. If rpc_count increases, more network roundtrips have
495
492
self.assertLength(24, self.hpss_calls)
496
493
self.assertLength(4, self.hpss_connections)
497
494
self.assertThat(self.hpss_calls, ContainsNoVfsCalls)
500
class TestSwitchUncommitted(TestCaseWithTransport):
503
tree = self.make_branch_and_tree('orig')
505
tree.branch.bzrdir.sprout('new')
506
checkout = tree.branch.create_checkout('checkout', lightweight=True)
507
self.build_tree(['checkout/a'])
508
self.assertPathExists('checkout/a')
511
def test_switch_stores_local(self):
513
self.run_bzr(['switch', '-d', 'checkout', 'new'])
514
self.assertPathDoesNotExist('checkout/a')
515
self.run_bzr(['switch', '-d', 'checkout', 'orig'])
516
self.assertPathExists('checkout/a')
518
def test_with_changes_does_not_store(self):
520
self.run_bzr(['switch', '-d', 'checkout', '--with-changes', 'new'])
521
self.assertPathExists('checkout/a')
523
def test_with_changes_does_not_restore(self):
525
self.run_bzr(['switch', '-d', 'checkout', 'new'])
526
self.assertPathDoesNotExist('checkout/a')
527
self.run_bzr(['switch', '-d', 'checkout', '--with-changes', 'orig'])
528
self.assertPathDoesNotExist('checkout/a')