~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Jelmer Vernooij
  • Date: 2011-12-16 16:40:10 UTC
  • mto: This revision was merged to the branch mainline in revision 6391.
  • Revision ID: jelmer@samba.org-20111216164010-z3hy00xrnclnkf7a
Update tests.

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 .')
184
187
        self.run_bzr('move a b')
185
188
        self.run_bzr('rename b a')
186
189
 
 
190
    def test_mv_no_root(self):
 
191
        tree = self.make_branch_and_tree('.')
 
192
        self.run_bzr_error(
 
193
            ["bzr: ERROR: can not move root of branch"],
 
194
            'mv . a')
 
195
 
187
196
    def test_mv_through_symlinks(self):
188
197
        self.requireFeature(SymlinkFeature)
189
198
        tree = self.make_branch_and_tree('.')
229
238
            ["^bzr: ERROR: Could not move a => b. b is already versioned\.$"],
230
239
            'mv a b')
231
240
        #check that nothing changed
232
 
        self.failIfExists('a')
233
 
        self.failUnlessExists('b')
 
241
        self.assertPathDoesNotExist('a')
 
242
        self.assertPathExists('b')
234
243
 
235
244
    def test_mv_already_moved_file_into_subdir(self):
236
245
        """Test bzr mv original_file to versioned_directory/file.
264
273
        self.run_bzr_error(
265
274
            ["^bzr: ERROR: Could not move a => a: sub is not versioned\.$"],
266
275
            'mv a sub/a')
267
 
        self.failIfExists('a')
268
 
        self.failUnlessExists('sub/a')
 
276
        self.assertPathDoesNotExist('a')
 
277
        self.assertPathExists('sub/a')
269
278
 
270
279
    def test_mv_already_moved_files_into_subdir(self):
271
280
        """Test bzr mv original_files to versioned_directory.
300
309
        self.run_bzr_error(
301
310
            ["^bzr: ERROR: Could not move to sub. sub is not versioned\.$"],
302
311
            'mv a1 a2 sub')
303
 
        self.failIfExists('a1')
304
 
        self.failUnlessExists('sub/a1')
305
 
        self.failUnlessExists('a2')
306
 
        self.failIfExists('sub/a2')
 
312
        self.assertPathDoesNotExist('a1')
 
313
        self.assertPathExists('sub/a1')
 
314
        self.assertPathExists('a2')
 
315
        self.assertPathDoesNotExist('sub/a2')
307
316
 
308
317
    def test_mv_already_moved_file_forcing_after(self):
309
318
        """Test bzr mv versioned_file to unversioned_file.
325
334
             " \(Use --after to tell bzr about a rename that has already"
326
335
             " happened\)$"],
327
336
            'mv a b')
328
 
        self.failUnlessExists('a')
329
 
        self.failUnlessExists('b')
 
337
        self.assertPathExists('a')
 
338
        self.assertPathExists('b')
330
339
 
331
340
    def test_mv_already_moved_file_using_after(self):
332
341
        """Test bzr mv --after versioned_file to unversioned_file.
346
355
        self.build_tree(['a']) #touch a
347
356
 
348
357
        self.run_bzr('mv a b --after')
349
 
        self.failUnlessExists('a')
 
358
        self.assertPathExists('a')
350
359
        self.assertNotInWorkingTree('a')#a should be unknown now.
351
 
        self.failUnlessExists('b')
 
360
        self.assertPathExists('b')
352
361
        self.assertInWorkingTree('b')
353
362
 
354
363
    def test_mv_already_moved_files_forcing_after(self):
375
384
             " exist. \(Use --after to tell bzr about a rename that has already"
376
385
             " happened\)$"],
377
386
            'mv a1 a2 sub')
378
 
        self.failUnlessExists('a1')
379
 
        self.failUnlessExists('a2')
380
 
        self.failUnlessExists('sub/a1')
381
 
        self.failUnlessExists('sub/a2')
 
387
        self.assertPathExists('a1')
 
388
        self.assertPathExists('a2')
 
389
        self.assertPathExists('sub/a1')
 
390
        self.assertPathExists('sub/a2')
382
391
 
383
392
    def test_mv_already_moved_files_using_after(self):
384
393
        """Test bzr mv --after versioned_file to directory/unversioned_file.
402
411
        self.build_tree(['a2']) #touch a2
403
412
 
404
413
        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')
 
414
        self.assertPathExists('a1')
 
415
        self.assertPathExists('a2')
 
416
        self.assertPathExists('sub/a1')
 
417
        self.assertPathExists('sub/a2')
409
418
        self.assertInWorkingTree('sub/a1')
410
419
        self.assertInWorkingTree('sub/a2')
411
420
 
421
430
        osutils.rename('c', 'd')
422
431
        # mv a b should work just like it does for already renamed files
423
432
        self.run_bzr('mv a b')
424
 
        self.failIfExists('a')
 
433
        self.assertPathDoesNotExist('a')
425
434
        self.assertNotInWorkingTree('a')
426
 
        self.failUnlessExists('b')
 
435
        self.assertPathExists('b')
427
436
        self.assertInWorkingTree('b')
428
437
        # and --after should work, too (technically it's ignored)
429
438
        self.run_bzr('mv --after c d')
430
 
        self.failIfExists('c')
 
439
        self.assertPathDoesNotExist('c')
431
440
        self.assertNotInWorkingTree('c')
432
 
        self.failUnlessExists('d')
 
441
        self.assertPathExists('d')
433
442
        self.assertInWorkingTree('d')
434
443
 
435
444
    def make_abcd_tree(self):
504
513
        # If this fails, the tree is trying to acquire a branch lock, which it
505
514
        # shouldn't.
506
515
        self.run_bzr(['mv', 'tree/path', 'tree/path2'])
 
516
 
 
517
    def test_mv_unversioned_non_ascii(self):
 
518
        """Clear error on mv of an unversioned non-ascii file, see lp:707954"""
 
519
        self.requireFeature(UnicodeFilenameFeature)
 
520
        tree = self.make_branch_and_tree(".")
 
521
        self.build_tree([u"\xA7"])
 
522
        out, err = self.run_bzr_error(["Could not rename", "not versioned"],
 
523
            ["mv", u"\xA7", "b"])
 
524
 
 
525
    def test_mv_removed_non_ascii(self):
 
526
        """Clear error on mv of a removed non-ascii file, see lp:898541"""
 
527
        self.requireFeature(UnicodeFilenameFeature)
 
528
        tree = self.make_branch_and_tree(".")
 
529
        self.build_tree([u"\xA7"])
 
530
        tree.add([u"\xA7"])
 
531
        tree.commit(u"Adding \xA7")
 
532
        os.remove(u"\xA7")
 
533
        out, err = self.run_bzr_error(["Could not rename", "not exist"],
 
534
            ["mv", u"\xA7", "b"])