427
420
osutils.rename('c', 'd')
428
421
# mv a b should work just like it does for already renamed files
429
422
self.run_bzr('mv a b')
430
self.assertPathDoesNotExist('a')
423
self.failIfExists('a')
431
424
self.assertNotInWorkingTree('a')
432
self.assertPathExists('b')
425
self.failUnlessExists('b')
433
426
self.assertInWorkingTree('b')
434
427
# and --after should work, too (technically it's ignored)
435
428
self.run_bzr('mv --after c d')
436
self.assertPathDoesNotExist('c')
429
self.failIfExists('c')
437
430
self.assertNotInWorkingTree('c')
438
self.assertPathExists('d')
431
self.failUnlessExists('d')
439
432
self.assertInWorkingTree('d')
441
def make_abcd_tree(self):
442
tree = self.make_branch_and_tree('tree')
443
self.build_tree(['tree/a', 'tree/c'])
445
tree.commit('record old names')
446
osutils.rename('tree/a', 'tree/b')
447
osutils.rename('tree/c', 'tree/d')
450
def test_mv_auto(self):
451
self.make_abcd_tree()
452
out, err = self.run_bzr('mv --auto', working_dir='tree')
453
self.assertEqual(out, '')
454
self.assertEqual(err, 'a => b\nc => d\n')
455
tree = workingtree.WorkingTree.open('tree')
456
self.assertIsNot(None, tree.path2id('b'))
457
self.assertIsNot(None, tree.path2id('d'))
459
def test_mv_auto_one_path(self):
460
self.make_abcd_tree()
461
out, err = self.run_bzr('mv --auto tree')
462
self.assertEqual(out, '')
463
self.assertEqual(err, 'a => b\nc => d\n')
464
tree = workingtree.WorkingTree.open('tree')
465
self.assertIsNot(None, tree.path2id('b'))
466
self.assertIsNot(None, tree.path2id('d'))
468
def test_mv_auto_two_paths(self):
469
self.make_abcd_tree()
470
out, err = self.run_bzr('mv --auto tree tree2', retcode=3)
471
self.assertEqual('bzr: ERROR: Only one path may be specified to'
474
def test_mv_auto_dry_run(self):
475
self.make_abcd_tree()
476
out, err = self.run_bzr('mv --auto --dry-run', working_dir='tree')
477
self.assertEqual(out, '')
478
self.assertEqual(err, 'a => b\nc => d\n')
479
tree = workingtree.WorkingTree.open('tree')
480
self.assertIsNot(None, tree.path2id('a'))
481
self.assertIsNot(None, tree.path2id('c'))
483
def test_mv_no_auto_dry_run(self):
484
self.make_abcd_tree()
485
out, err = self.run_bzr('mv c d --dry-run',
486
working_dir='tree', retcode=3)
487
self.assertEqual('bzr: ERROR: --dry-run requires --auto.\n', err)
489
def test_mv_auto_after(self):
490
self.make_abcd_tree()
491
out, err = self.run_bzr('mv --auto --after', working_dir='tree',
493
self.assertEqual('bzr: ERROR: --after cannot be specified with'
496
def test_mv_quiet(self):
497
tree = self.make_branch_and_tree('.')
498
self.build_tree(['aaa'])
500
out, err = self.run_bzr('mv --quiet aaa bbb')
501
self.assertEqual(out, '')
502
self.assertEqual(err, '')
504
def test_mv_readonly_lightweight_checkout(self):
505
branch = self.make_branch('foo')
506
branch = bzrlib.branch.Branch.open(self.get_readonly_url('foo'))
507
tree = branch.create_checkout('tree', lightweight=True)
508
self.build_tree(['tree/path'])
510
# If this fails, the tree is trying to acquire a branch lock, which it
512
self.run_bzr(['mv', 'tree/path', 'tree/path2'])
514
def test_mv_unversioned_non_ascii(self):
515
"""Clear error on mv of an unversioned non-ascii file, see lp:707954"""
516
self.requireFeature(UnicodeFilenameFeature)
517
tree = self.make_branch_and_tree(".")
518
self.build_tree([u"\xA7"])
519
out, err = self.run_bzr_error(["Could not rename", "not versioned"],
520
["mv", u"\xA7", "b"])
522
def test_mv_removed_non_ascii(self):
523
"""Clear error on mv of a removed non-ascii file, see lp:898541"""
524
self.requireFeature(UnicodeFilenameFeature)
525
tree = self.make_branch_and_tree(".")
526
self.build_tree([u"\xA7"])
528
tree.commit(u"Adding \xA7")
530
out, err = self.run_bzr_error(["Could not rename", "not exist"],
531
["mv", u"\xA7", "b"])