~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

(gz) Fix test failure on alpha by correcting format string for
 gc_chk_sha1_record (Martin [gz])

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
    )
26
26
 
27
27
from bzrlib.tests import (
28
 
    TestCaseWithTransport,
29
 
    )
30
 
from bzrlib.tests.features import (
31
28
    CaseInsensitiveFilesystemFeature,
32
29
    SymlinkFeature,
33
 
    UnicodeFilenameFeature,
 
30
    TestCaseWithTransport,
 
31
    UnicodeFilename,
34
32
    )
35
33
 
36
34
 
38
36
 
39
37
    def assertMoved(self,from_path,to_path):
40
38
        """Assert that to_path is existing and versioned but from_path not. """
41
 
        self.assertPathDoesNotExist(from_path)
 
39
        self.failIfExists(from_path)
42
40
        self.assertNotInWorkingTree(from_path)
43
41
 
44
 
        self.assertPathExists(to_path)
 
42
        self.failUnlessExists(to_path)
45
43
        self.assertInWorkingTree(to_path)
46
44
 
47
45
    def test_mv_modes(self):
122
120
 
123
121
        os.chdir('sub1/sub2')
124
122
        self.run_bzr('mv ../hello.txt .')
125
 
        self.assertPathExists('./hello.txt')
 
123
        self.failUnlessExists('./hello.txt')
126
124
 
127
125
        os.chdir('..')
128
126
        self.run_bzr('mv sub2/hello.txt .')
232
230
            ["^bzr: ERROR: Could not move a => b. b is already versioned\.$"],
233
231
            'mv a b')
234
232
        #check that nothing changed
235
 
        self.assertPathDoesNotExist('a')
236
 
        self.assertPathExists('b')
 
233
        self.failIfExists('a')
 
234
        self.failUnlessExists('b')
237
235
 
238
236
    def test_mv_already_moved_file_into_subdir(self):
239
237
        """Test bzr mv original_file to versioned_directory/file.
267
265
        self.run_bzr_error(
268
266
            ["^bzr: ERROR: Could not move a => a: sub is not versioned\.$"],
269
267
            'mv a sub/a')
270
 
        self.assertPathDoesNotExist('a')
271
 
        self.assertPathExists('sub/a')
 
268
        self.failIfExists('a')
 
269
        self.failUnlessExists('sub/a')
272
270
 
273
271
    def test_mv_already_moved_files_into_subdir(self):
274
272
        """Test bzr mv original_files to versioned_directory.
303
301
        self.run_bzr_error(
304
302
            ["^bzr: ERROR: Could not move to sub. sub is not versioned\.$"],
305
303
            'mv a1 a2 sub')
306
 
        self.assertPathDoesNotExist('a1')
307
 
        self.assertPathExists('sub/a1')
308
 
        self.assertPathExists('a2')
309
 
        self.assertPathDoesNotExist('sub/a2')
 
304
        self.failIfExists('a1')
 
305
        self.failUnlessExists('sub/a1')
 
306
        self.failUnlessExists('a2')
 
307
        self.failIfExists('sub/a2')
310
308
 
311
309
    def test_mv_already_moved_file_forcing_after(self):
312
310
        """Test bzr mv versioned_file to unversioned_file.
328
326
             " \(Use --after to tell bzr about a rename that has already"
329
327
             " happened\)$"],
330
328
            'mv a b')
331
 
        self.assertPathExists('a')
332
 
        self.assertPathExists('b')
 
329
        self.failUnlessExists('a')
 
330
        self.failUnlessExists('b')
333
331
 
334
332
    def test_mv_already_moved_file_using_after(self):
335
333
        """Test bzr mv --after versioned_file to unversioned_file.
349
347
        self.build_tree(['a']) #touch a
350
348
 
351
349
        self.run_bzr('mv a b --after')
352
 
        self.assertPathExists('a')
 
350
        self.failUnlessExists('a')
353
351
        self.assertNotInWorkingTree('a')#a should be unknown now.
354
 
        self.assertPathExists('b')
 
352
        self.failUnlessExists('b')
355
353
        self.assertInWorkingTree('b')
356
354
 
357
355
    def test_mv_already_moved_files_forcing_after(self):
378
376
             " exist. \(Use --after to tell bzr about a rename that has already"
379
377
             " happened\)$"],
380
378
            'mv a1 a2 sub')
381
 
        self.assertPathExists('a1')
382
 
        self.assertPathExists('a2')
383
 
        self.assertPathExists('sub/a1')
384
 
        self.assertPathExists('sub/a2')
 
379
        self.failUnlessExists('a1')
 
380
        self.failUnlessExists('a2')
 
381
        self.failUnlessExists('sub/a1')
 
382
        self.failUnlessExists('sub/a2')
385
383
 
386
384
    def test_mv_already_moved_files_using_after(self):
387
385
        """Test bzr mv --after versioned_file to directory/unversioned_file.
405
403
        self.build_tree(['a2']) #touch a2
406
404
 
407
405
        self.run_bzr('mv a1 a2 sub --after')
408
 
        self.assertPathExists('a1')
409
 
        self.assertPathExists('a2')
410
 
        self.assertPathExists('sub/a1')
411
 
        self.assertPathExists('sub/a2')
 
406
        self.failUnlessExists('a1')
 
407
        self.failUnlessExists('a2')
 
408
        self.failUnlessExists('sub/a1')
 
409
        self.failUnlessExists('sub/a2')
412
410
        self.assertInWorkingTree('sub/a1')
413
411
        self.assertInWorkingTree('sub/a2')
414
412
 
424
422
        osutils.rename('c', 'd')
425
423
        # mv a b should work just like it does for already renamed files
426
424
        self.run_bzr('mv a b')
427
 
        self.assertPathDoesNotExist('a')
 
425
        self.failIfExists('a')
428
426
        self.assertNotInWorkingTree('a')
429
 
        self.assertPathExists('b')
 
427
        self.failUnlessExists('b')
430
428
        self.assertInWorkingTree('b')
431
429
        # and --after should work, too (technically it's ignored)
432
430
        self.run_bzr('mv --after c d')
433
 
        self.assertPathDoesNotExist('c')
 
431
        self.failIfExists('c')
434
432
        self.assertNotInWorkingTree('c')
435
 
        self.assertPathExists('d')
 
433
        self.failUnlessExists('d')
436
434
        self.assertInWorkingTree('d')
437
435
 
438
436
    def make_abcd_tree(self):
510
508
 
511
509
    def test_mv_unversioned_non_ascii(self):
512
510
        """Clear error on mv of an unversioned non-ascii file, see lp:707954"""
513
 
        self.requireFeature(UnicodeFilenameFeature)
 
511
        self.requireFeature(UnicodeFilename)
514
512
        tree = self.make_branch_and_tree(".")
515
513
        self.build_tree([u"\xA7"])
516
514
        out, err = self.run_bzr_error(["Could not rename", "not versioned"],