~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Matt Nordhoff
  • Date: 2009-04-04 02:50:01 UTC
  • mfrom: (4253 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4256.
  • Revision ID: mnordhoff@mattnordhoff.com-20090404025001-z1403k0tatmc8l91
Merge bzr.dev, fixing conflicts.

Show diffs side-by-side

added added

removed removed

Lines of Context:
12
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
16
 
17
17
"""Test for 'bzr mv'"""
18
18
 
77
77
 
78
78
    def test_mv_unqualified(self):
79
79
        self.run_bzr_error(['^bzr: ERROR: missing file argument$'], 'mv')
80
 
        
 
80
 
81
81
    def test_mv_invalid(self):
82
82
        tree = self.make_branch_and_tree('.')
83
83
        self.build_tree(['test.txt', 'sub1/'])
91
91
            ["^bzr: ERROR: Could not move test.txt => .*hello.txt: "
92
92
             "sub1 is not versioned\.$"],
93
93
            'mv test.txt sub1/hello.txt')
94
 
        
 
94
 
95
95
    def test_mv_dirs(self):
96
96
        tree = self.make_branch_and_tree('.')
97
97
        self.build_tree(['hello.txt', 'sub1/'])
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)