~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: 2010-05-11 11:47:36 UTC
  • mfrom: (5200.3.8 lock_return)
  • Revision ID: pqm@pqm.ubuntu.com-20100511114736-mc1sq9zyo3vufec7
(lifeless) Provide a consistent interface to Tree, Branch,
 Repository where lock methods return an object with an unlock method to
 unlock the lock. This breaks the API for Branch,
 Repository on their lock_write methods. (Robert Collins)

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