~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: 2011-04-18 04:55:00 UTC
  • mfrom: (5784.2.1 754188-apport-test)
  • Revision ID: pqm@pqm.ubuntu.com-20110418045500-ce6lkgyiq7f47q43
(mbp) Rewrite test_report_bug_legacy away from using doctest (see bug
 764188) (Martin Pool)

Show diffs side-by-side

added added

removed removed

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