431
430
self.assertNotInWorkingTree('c')
432
431
self.failUnlessExists('d')
433
432
self.assertInWorkingTree('d')
435
def make_abcd_tree(self):
436
tree = self.make_branch_and_tree('tree')
437
self.build_tree(['tree/a', 'tree/c'])
439
tree.commit('record old names')
440
osutils.rename('tree/a', 'tree/b')
441
osutils.rename('tree/c', 'tree/d')
444
def test_mv_auto(self):
445
self.make_abcd_tree()
446
out, err = self.run_bzr('mv --auto', working_dir='tree')
447
self.assertEqual(out, '')
448
self.assertEqual(err, 'a => b\nc => d\n')
449
tree = workingtree.WorkingTree.open('tree')
450
self.assertIsNot(None, tree.path2id('b'))
451
self.assertIsNot(None, tree.path2id('d'))
453
def test_mv_auto_one_path(self):
454
self.make_abcd_tree()
455
out, err = self.run_bzr('mv --auto tree')
456
self.assertEqual(out, '')
457
self.assertEqual(err, 'a => b\nc => d\n')
458
tree = workingtree.WorkingTree.open('tree')
459
self.assertIsNot(None, tree.path2id('b'))
460
self.assertIsNot(None, tree.path2id('d'))
462
def test_mv_auto_two_paths(self):
463
self.make_abcd_tree()
464
out, err = self.run_bzr('mv --auto tree tree2', retcode=3)
465
self.assertEqual('bzr: ERROR: Only one path may be specified to'
468
def test_mv_auto_dry_run(self):
469
self.make_abcd_tree()
470
out, err = self.run_bzr('mv --auto --dry-run', working_dir='tree')
471
self.assertEqual(out, '')
472
self.assertEqual(err, 'a => b\nc => d\n')
473
tree = workingtree.WorkingTree.open('tree')
474
self.assertIsNot(None, tree.path2id('a'))
475
self.assertIsNot(None, tree.path2id('c'))
477
def test_mv_no_auto_dry_run(self):
478
self.make_abcd_tree()
479
out, err = self.run_bzr('mv c d --dry-run',
480
working_dir='tree', retcode=3)
481
self.assertEqual('bzr: ERROR: --dry-run requires --auto.\n', err)
483
def test_mv_auto_after(self):
484
self.make_abcd_tree()
485
out, err = self.run_bzr('mv --auto --after', working_dir='tree',
487
self.assertEqual('bzr: ERROR: --after cannot be specified with'
490
def test_mv_quiet(self):
491
tree = self.make_branch_and_tree('.')
492
self.build_tree(['aaa'])
494
out, err = self.run_bzr('mv --quiet aaa bbb')
495
self.assertEqual(out, '')
496
self.assertEqual(err, '')
498
def test_mv_readonly_lightweight_checkout(self):
499
branch = self.make_branch('foo')
500
branch = bzrlib.branch.Branch.open(self.get_readonly_url('foo'))
501
tree = branch.create_checkout('tree', lightweight=True)
502
self.build_tree(['tree/path'])
504
# If this fails, the tree is trying to acquire a branch lock, which it
506
self.run_bzr(['mv', 'tree/path', 'tree/path2'])