~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

(jameinel) Allow 'bzr serve' to interpret SIGHUP as a graceful shutdown.
 (bug #795025) (John A Meinel)

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