~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Patch Queue Manager
  • Date: 2013-10-07 17:04:34 UTC
  • mfrom: (6588.1.1 trunk)
  • Revision ID: pqm@pqm.ubuntu.com-20131007170434-mb0ahksmrzsnhi1i
(vila) Stricter checks on configuration option names (Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2010 Canonical Ltd
 
1
# Copyright (C) 2006-2012 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
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,
31
 
    UnicodeFilename,
 
33
    UnicodeFilenameFeature,
32
34
    )
33
35
 
34
36
 
36
38
 
37
39
    def assertMoved(self,from_path,to_path):
38
40
        """Assert that to_path is existing and versioned but from_path not. """
39
 
        self.failIfExists(from_path)
 
41
        self.assertPathDoesNotExist(from_path)
40
42
        self.assertNotInWorkingTree(from_path)
41
43
 
42
 
        self.failUnlessExists(to_path)
 
44
        self.assertPathExists(to_path)
43
45
        self.assertInWorkingTree(to_path)
44
46
 
45
47
    def test_mv_modes(self):
118
120
        tree = self.make_branch_and_tree('.')
119
121
        tree.add(['sub1', 'sub1/sub2', 'sub1/hello.txt'])
120
122
 
121
 
        os.chdir('sub1/sub2')
122
 
        self.run_bzr('mv ../hello.txt .')
123
 
        self.failUnlessExists('./hello.txt')
 
123
        self.run_bzr('mv ../hello.txt .', working_dir='sub1/sub2')
 
124
        self.assertPathExists('sub1/sub2/hello.txt')
124
125
 
125
 
        os.chdir('..')
126
 
        self.run_bzr('mv sub2/hello.txt .')
127
 
        os.chdir('..')
 
126
        self.run_bzr('mv sub2/hello.txt .', working_dir='sub1')
128
127
        self.assertMoved('sub1/sub2/hello.txt','sub1/hello.txt')
129
128
 
130
129
    def test_mv_change_case_file(self):
185
184
        self.run_bzr('move a b')
186
185
        self.run_bzr('rename b a')
187
186
 
 
187
    def test_mv_no_root(self):
 
188
        tree = self.make_branch_and_tree('.')
 
189
        self.run_bzr_error(
 
190
            ["bzr: ERROR: can not move root of branch"],
 
191
            'mv . a')
 
192
 
188
193
    def test_mv_through_symlinks(self):
189
194
        self.requireFeature(SymlinkFeature)
190
195
        tree = self.make_branch_and_tree('.')
230
235
            ["^bzr: ERROR: Could not move a => b. b is already versioned\.$"],
231
236
            'mv a b')
232
237
        #check that nothing changed
233
 
        self.failIfExists('a')
234
 
        self.failUnlessExists('b')
 
238
        self.assertPathDoesNotExist('a')
 
239
        self.assertPathExists('b')
235
240
 
236
241
    def test_mv_already_moved_file_into_subdir(self):
237
242
        """Test bzr mv original_file to versioned_directory/file.
265
270
        self.run_bzr_error(
266
271
            ["^bzr: ERROR: Could not move a => a: sub is not versioned\.$"],
267
272
            'mv a sub/a')
268
 
        self.failIfExists('a')
269
 
        self.failUnlessExists('sub/a')
 
273
        self.assertPathDoesNotExist('a')
 
274
        self.assertPathExists('sub/a')
270
275
 
271
276
    def test_mv_already_moved_files_into_subdir(self):
272
277
        """Test bzr mv original_files to versioned_directory.
301
306
        self.run_bzr_error(
302
307
            ["^bzr: ERROR: Could not move to sub. sub is not versioned\.$"],
303
308
            'mv a1 a2 sub')
304
 
        self.failIfExists('a1')
305
 
        self.failUnlessExists('sub/a1')
306
 
        self.failUnlessExists('a2')
307
 
        self.failIfExists('sub/a2')
 
309
        self.assertPathDoesNotExist('a1')
 
310
        self.assertPathExists('sub/a1')
 
311
        self.assertPathExists('a2')
 
312
        self.assertPathDoesNotExist('sub/a2')
308
313
 
309
314
    def test_mv_already_moved_file_forcing_after(self):
310
315
        """Test bzr mv versioned_file to unversioned_file.
326
331
             " \(Use --after to tell bzr about a rename that has already"
327
332
             " happened\)$"],
328
333
            'mv a b')
329
 
        self.failUnlessExists('a')
330
 
        self.failUnlessExists('b')
 
334
        self.assertPathExists('a')
 
335
        self.assertPathExists('b')
331
336
 
332
337
    def test_mv_already_moved_file_using_after(self):
333
338
        """Test bzr mv --after versioned_file to unversioned_file.
347
352
        self.build_tree(['a']) #touch a
348
353
 
349
354
        self.run_bzr('mv a b --after')
350
 
        self.failUnlessExists('a')
 
355
        self.assertPathExists('a')
351
356
        self.assertNotInWorkingTree('a')#a should be unknown now.
352
 
        self.failUnlessExists('b')
 
357
        self.assertPathExists('b')
353
358
        self.assertInWorkingTree('b')
354
359
 
355
360
    def test_mv_already_moved_files_forcing_after(self):
376
381
             " exist. \(Use --after to tell bzr about a rename that has already"
377
382
             " happened\)$"],
378
383
            'mv a1 a2 sub')
379
 
        self.failUnlessExists('a1')
380
 
        self.failUnlessExists('a2')
381
 
        self.failUnlessExists('sub/a1')
382
 
        self.failUnlessExists('sub/a2')
 
384
        self.assertPathExists('a1')
 
385
        self.assertPathExists('a2')
 
386
        self.assertPathExists('sub/a1')
 
387
        self.assertPathExists('sub/a2')
383
388
 
384
389
    def test_mv_already_moved_files_using_after(self):
385
390
        """Test bzr mv --after versioned_file to directory/unversioned_file.
403
408
        self.build_tree(['a2']) #touch a2
404
409
 
405
410
        self.run_bzr('mv a1 a2 sub --after')
406
 
        self.failUnlessExists('a1')
407
 
        self.failUnlessExists('a2')
408
 
        self.failUnlessExists('sub/a1')
409
 
        self.failUnlessExists('sub/a2')
 
411
        self.assertPathExists('a1')
 
412
        self.assertPathExists('a2')
 
413
        self.assertPathExists('sub/a1')
 
414
        self.assertPathExists('sub/a2')
410
415
        self.assertInWorkingTree('sub/a1')
411
416
        self.assertInWorkingTree('sub/a2')
412
417
 
422
427
        osutils.rename('c', 'd')
423
428
        # mv a b should work just like it does for already renamed files
424
429
        self.run_bzr('mv a b')
425
 
        self.failIfExists('a')
 
430
        self.assertPathDoesNotExist('a')
426
431
        self.assertNotInWorkingTree('a')
427
 
        self.failUnlessExists('b')
 
432
        self.assertPathExists('b')
428
433
        self.assertInWorkingTree('b')
429
434
        # and --after should work, too (technically it's ignored)
430
435
        self.run_bzr('mv --after c d')
431
 
        self.failIfExists('c')
 
436
        self.assertPathDoesNotExist('c')
432
437
        self.assertNotInWorkingTree('c')
433
 
        self.failUnlessExists('d')
 
438
        self.assertPathExists('d')
434
439
        self.assertInWorkingTree('d')
435
440
 
436
441
    def make_abcd_tree(self):
508
513
 
509
514
    def test_mv_unversioned_non_ascii(self):
510
515
        """Clear error on mv of an unversioned non-ascii file, see lp:707954"""
511
 
        self.requireFeature(UnicodeFilename)
 
516
        self.requireFeature(UnicodeFilenameFeature)
512
517
        tree = self.make_branch_and_tree(".")
513
518
        self.build_tree([u"\xA7"])
514
519
        out, err = self.run_bzr_error(["Could not rename", "not versioned"],
515
520
            ["mv", u"\xA7", "b"])
 
521
 
 
522
    def test_mv_removed_non_ascii(self):
 
523
        """Clear error on mv of a removed non-ascii file, see lp:898541"""
 
524
        self.requireFeature(UnicodeFilenameFeature)
 
525
        tree = self.make_branch_and_tree(".")
 
526
        self.build_tree([u"\xA7"])
 
527
        tree.add([u"\xA7"])
 
528
        tree.commit(u"Adding \xA7")
 
529
        os.remove(u"\xA7")
 
530
        out, err = self.run_bzr_error(["Could not rename", "not exist"],
 
531
            ["mv", u"\xA7", "b"])