~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Johan Walles
  • Date: 2009-05-07 05:08:46 UTC
  • mfrom: (4342 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4343.
  • Revision ID: johan.walles@gmail.com-20090507050846-nkwvcyauf1eh653q
MergeĀ fromĀ upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
1
# Copyright (C) 2006 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
18
18
 
19
19
import os
20
20
 
21
 
import bzrlib.branch
22
21
from bzrlib import (
23
22
    osutils,
24
23
    workingtree,
28
27
    CaseInsensitiveFilesystemFeature,
29
28
    SymlinkFeature,
30
29
    TestCaseWithTransport,
31
 
    UnicodeFilename,
32
30
    )
33
31
 
34
32
 
36
34
 
37
35
    def assertMoved(self,from_path,to_path):
38
36
        """Assert that to_path is existing and versioned but from_path not. """
39
 
        self.assertPathDoesNotExist(from_path)
 
37
        self.failIfExists(from_path)
40
38
        self.assertNotInWorkingTree(from_path)
41
39
 
42
 
        self.assertPathExists(to_path)
 
40
        self.failUnlessExists(to_path)
43
41
        self.assertInWorkingTree(to_path)
44
42
 
45
43
    def test_mv_modes(self):
120
118
 
121
119
        os.chdir('sub1/sub2')
122
120
        self.run_bzr('mv ../hello.txt .')
123
 
        self.assertPathExists('./hello.txt')
 
121
        self.failUnlessExists('./hello.txt')
124
122
 
125
123
        os.chdir('..')
126
124
        self.run_bzr('mv sub2/hello.txt .')
230
228
            ["^bzr: ERROR: Could not move a => b. b is already versioned\.$"],
231
229
            'mv a b')
232
230
        #check that nothing changed
233
 
        self.assertPathDoesNotExist('a')
234
 
        self.assertPathExists('b')
 
231
        self.failIfExists('a')
 
232
        self.failUnlessExists('b')
235
233
 
236
234
    def test_mv_already_moved_file_into_subdir(self):
237
235
        """Test bzr mv original_file to versioned_directory/file.
265
263
        self.run_bzr_error(
266
264
            ["^bzr: ERROR: Could not move a => a: sub is not versioned\.$"],
267
265
            'mv a sub/a')
268
 
        self.assertPathDoesNotExist('a')
269
 
        self.assertPathExists('sub/a')
 
266
        self.failIfExists('a')
 
267
        self.failUnlessExists('sub/a')
270
268
 
271
269
    def test_mv_already_moved_files_into_subdir(self):
272
270
        """Test bzr mv original_files to versioned_directory.
301
299
        self.run_bzr_error(
302
300
            ["^bzr: ERROR: Could not move to sub. sub is not versioned\.$"],
303
301
            'mv a1 a2 sub')
304
 
        self.assertPathDoesNotExist('a1')
305
 
        self.assertPathExists('sub/a1')
306
 
        self.assertPathExists('a2')
307
 
        self.assertPathDoesNotExist('sub/a2')
 
302
        self.failIfExists('a1')
 
303
        self.failUnlessExists('sub/a1')
 
304
        self.failUnlessExists('a2')
 
305
        self.failIfExists('sub/a2')
308
306
 
309
307
    def test_mv_already_moved_file_forcing_after(self):
310
308
        """Test bzr mv versioned_file to unversioned_file.
326
324
             " \(Use --after to tell bzr about a rename that has already"
327
325
             " happened\)$"],
328
326
            'mv a b')
329
 
        self.assertPathExists('a')
330
 
        self.assertPathExists('b')
 
327
        self.failUnlessExists('a')
 
328
        self.failUnlessExists('b')
331
329
 
332
330
    def test_mv_already_moved_file_using_after(self):
333
331
        """Test bzr mv --after versioned_file to unversioned_file.
347
345
        self.build_tree(['a']) #touch a
348
346
 
349
347
        self.run_bzr('mv a b --after')
350
 
        self.assertPathExists('a')
 
348
        self.failUnlessExists('a')
351
349
        self.assertNotInWorkingTree('a')#a should be unknown now.
352
 
        self.assertPathExists('b')
 
350
        self.failUnlessExists('b')
353
351
        self.assertInWorkingTree('b')
354
352
 
355
353
    def test_mv_already_moved_files_forcing_after(self):
376
374
             " exist. \(Use --after to tell bzr about a rename that has already"
377
375
             " happened\)$"],
378
376
            'mv a1 a2 sub')
379
 
        self.assertPathExists('a1')
380
 
        self.assertPathExists('a2')
381
 
        self.assertPathExists('sub/a1')
382
 
        self.assertPathExists('sub/a2')
 
377
        self.failUnlessExists('a1')
 
378
        self.failUnlessExists('a2')
 
379
        self.failUnlessExists('sub/a1')
 
380
        self.failUnlessExists('sub/a2')
383
381
 
384
382
    def test_mv_already_moved_files_using_after(self):
385
383
        """Test bzr mv --after versioned_file to directory/unversioned_file.
403
401
        self.build_tree(['a2']) #touch a2
404
402
 
405
403
        self.run_bzr('mv a1 a2 sub --after')
406
 
        self.assertPathExists('a1')
407
 
        self.assertPathExists('a2')
408
 
        self.assertPathExists('sub/a1')
409
 
        self.assertPathExists('sub/a2')
 
404
        self.failUnlessExists('a1')
 
405
        self.failUnlessExists('a2')
 
406
        self.failUnlessExists('sub/a1')
 
407
        self.failUnlessExists('sub/a2')
410
408
        self.assertInWorkingTree('sub/a1')
411
409
        self.assertInWorkingTree('sub/a2')
412
410
 
422
420
        osutils.rename('c', 'd')
423
421
        # mv a b should work just like it does for already renamed files
424
422
        self.run_bzr('mv a b')
425
 
        self.assertPathDoesNotExist('a')
 
423
        self.failIfExists('a')
426
424
        self.assertNotInWorkingTree('a')
427
 
        self.assertPathExists('b')
 
425
        self.failUnlessExists('b')
428
426
        self.assertInWorkingTree('b')
429
427
        # and --after should work, too (technically it's ignored)
430
428
        self.run_bzr('mv --after c d')
431
 
        self.assertPathDoesNotExist('c')
 
429
        self.failIfExists('c')
432
430
        self.assertNotInWorkingTree('c')
433
 
        self.assertPathExists('d')
 
431
        self.failUnlessExists('d')
434
432
        self.assertInWorkingTree('d')
435
433
 
436
434
    def make_abcd_tree(self):
487
485
                                retcode=3)
488
486
        self.assertEqual('bzr: ERROR: --after cannot be specified with'
489
487
                         ' --auto.\n', err)
490
 
 
491
 
    def test_mv_quiet(self):
492
 
        tree = self.make_branch_and_tree('.')
493
 
        self.build_tree(['aaa'])
494
 
        tree.add(['aaa'])
495
 
        out, err = self.run_bzr('mv --quiet aaa bbb')
496
 
        self.assertEqual(out, '')
497
 
        self.assertEqual(err, '')
498
 
 
499
 
    def test_mv_readonly_lightweight_checkout(self):
500
 
        branch = self.make_branch('foo')
501
 
        branch = bzrlib.branch.Branch.open(self.get_readonly_url('foo'))
502
 
        tree = branch.create_checkout('tree', lightweight=True)
503
 
        self.build_tree(['tree/path'])
504
 
        tree.add('path')
505
 
        # If this fails, the tree is trying to acquire a branch lock, which it
506
 
        # shouldn't.
507
 
        self.run_bzr(['mv', 'tree/path', 'tree/path2'])
508
 
 
509
 
    def test_mv_unversioned_non_ascii(self):
510
 
        """Clear error on mv of an unversioned non-ascii file, see lp:707954"""
511
 
        self.requireFeature(UnicodeFilename)
512
 
        tree = self.make_branch_and_tree(".")
513
 
        self.build_tree([u"\xA7"])
514
 
        out, err = self.run_bzr_error(["Could not rename", "not versioned"],
515
 
            ["mv", u"\xA7", "b"])