~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-04-02 16:35:02 UTC
  • mfrom: (3193.8.39 guess-renames)
  • Revision ID: pqm@pqm.ubuntu.com-20090402163502-ryn8zr2giilw5bki
(abentley) Change guess-renames to mv --auto, add --dry-run

Show diffs side-by-side

added added

removed removed

Lines of Context:
430
430
        self.assertNotInWorkingTree('c')
431
431
        self.failUnlessExists('d')
432
432
        self.assertInWorkingTree('d')
 
433
 
 
434
    def make_abcd_tree(self):
 
435
        tree = self.make_branch_and_tree('tree')
 
436
        self.build_tree(['tree/a', 'tree/c'])
 
437
        tree.add(['a', 'c'])
 
438
        tree.commit('record old names')
 
439
        osutils.rename('tree/a', 'tree/b')
 
440
        osutils.rename('tree/c', 'tree/d')
 
441
        return tree
 
442
 
 
443
    def test_mv_auto(self):
 
444
        self.make_abcd_tree()
 
445
        out, err = self.run_bzr('mv --auto', working_dir='tree')
 
446
        self.assertEqual(out, '')
 
447
        self.assertEqual(err, 'a => b\nc => d\n')
 
448
        tree = workingtree.WorkingTree.open('tree')
 
449
        self.assertIsNot(None, tree.path2id('b'))
 
450
        self.assertIsNot(None, tree.path2id('d'))
 
451
 
 
452
    def test_mv_auto_one_path(self):
 
453
        self.make_abcd_tree()
 
454
        out, err = self.run_bzr('mv --auto tree')
 
455
        self.assertEqual(out, '')
 
456
        self.assertEqual(err, 'a => b\nc => d\n')
 
457
        tree = workingtree.WorkingTree.open('tree')
 
458
        self.assertIsNot(None, tree.path2id('b'))
 
459
        self.assertIsNot(None, tree.path2id('d'))
 
460
 
 
461
    def test_mv_auto_two_paths(self):
 
462
        self.make_abcd_tree()
 
463
        out, err = self.run_bzr('mv --auto tree tree2', retcode=3)
 
464
        self.assertEqual('bzr: ERROR: Only one path may be specified to'
 
465
                         ' --auto.\n', err)
 
466
 
 
467
    def test_mv_auto_dry_run(self):
 
468
        self.make_abcd_tree()
 
469
        out, err = self.run_bzr('mv --auto --dry-run', working_dir='tree')
 
470
        self.assertEqual(out, '')
 
471
        self.assertEqual(err, 'a => b\nc => d\n')
 
472
        tree = workingtree.WorkingTree.open('tree')
 
473
        self.assertIsNot(None, tree.path2id('a'))
 
474
        self.assertIsNot(None, tree.path2id('c'))
 
475
 
 
476
    def test_mv_no_auto_dry_run(self):
 
477
        self.make_abcd_tree()
 
478
        out, err = self.run_bzr('mv c d --dry-run',
 
479
                                working_dir='tree', retcode=3)
 
480
        self.assertEqual('bzr: ERROR: --dry-run requires --auto.\n', err)
 
481
 
 
482
    def test_mv_auto_after(self):
 
483
        self.make_abcd_tree()
 
484
        out, err = self.run_bzr('mv --auto --after', working_dir='tree',
 
485
                                retcode=3)
 
486
        self.assertEqual('bzr: ERROR: --after cannot be specified with'
 
487
                         ' --auto.\n', err)