~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-08-24 23:20:14 UTC
  • mfrom: (5365.5.29 2.3-btree-chk-leaf)
  • Revision ID: pqm@pqm.ubuntu.com-20100824232014-nu9owzel2zym2jk2
(jam) Use a custom C type for CHK index entries, saves memory

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006-2012, 2016 Canonical Ltd
 
1
# Copyright (C) 2006-2010 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 (
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):
120
117
        tree = self.make_branch_and_tree('.')
121
118
        tree.add(['sub1', 'sub1/sub2', 'sub1/hello.txt'])
122
119
 
123
 
        self.run_bzr('mv ../hello.txt .', working_dir='sub1/sub2')
124
 
        self.assertPathExists('sub1/sub2/hello.txt')
 
120
        os.chdir('sub1/sub2')
 
121
        self.run_bzr('mv ../hello.txt .')
 
122
        self.failUnlessExists('./hello.txt')
125
123
 
126
 
        self.run_bzr('mv sub2/hello.txt .', working_dir='sub1')
 
124
        os.chdir('..')
 
125
        self.run_bzr('mv sub2/hello.txt .')
 
126
        os.chdir('..')
127
127
        self.assertMoved('sub1/sub2/hello.txt','sub1/hello.txt')
128
128
 
129
129
    def test_mv_change_case_file(self):
169
169
        self.build_tree(['foo/', 'bar'])
170
170
        tree.add(['foo', 'bar'])
171
171
        out, err = self.run_bzr('mv bar Foo', retcode=3)
172
 
        self.assertEqual('', out)
173
 
        self.assertEqual(
 
172
        self.assertEquals('', out)
 
173
        self.assertEquals(
174
174
            'bzr: ERROR: Could not move to Foo: Foo is not versioned.\n',
175
175
            err)
176
176
 
184
184
        self.run_bzr('move a b')
185
185
        self.run_bzr('rename b a')
186
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
 
 
193
187
    def test_mv_through_symlinks(self):
194
188
        self.requireFeature(SymlinkFeature)
195
189
        tree = self.make_branch_and_tree('.')
235
229
            ["^bzr: ERROR: Could not move a => b. b is already versioned\.$"],
236
230
            'mv a b')
237
231
        #check that nothing changed
238
 
        self.assertPathDoesNotExist('a')
239
 
        self.assertPathExists('b')
 
232
        self.failIfExists('a')
 
233
        self.failUnlessExists('b')
240
234
 
241
235
    def test_mv_already_moved_file_into_subdir(self):
242
236
        """Test bzr mv original_file to versioned_directory/file.
270
264
        self.run_bzr_error(
271
265
            ["^bzr: ERROR: Could not move a => a: sub is not versioned\.$"],
272
266
            'mv a sub/a')
273
 
        self.assertPathDoesNotExist('a')
274
 
        self.assertPathExists('sub/a')
 
267
        self.failIfExists('a')
 
268
        self.failUnlessExists('sub/a')
275
269
 
276
270
    def test_mv_already_moved_files_into_subdir(self):
277
271
        """Test bzr mv original_files to versioned_directory.
306
300
        self.run_bzr_error(
307
301
            ["^bzr: ERROR: Could not move to sub. sub is not versioned\.$"],
308
302
            'mv a1 a2 sub')
309
 
        self.assertPathDoesNotExist('a1')
310
 
        self.assertPathExists('sub/a1')
311
 
        self.assertPathExists('a2')
312
 
        self.assertPathDoesNotExist('sub/a2')
 
303
        self.failIfExists('a1')
 
304
        self.failUnlessExists('sub/a1')
 
305
        self.failUnlessExists('a2')
 
306
        self.failIfExists('sub/a2')
313
307
 
314
308
    def test_mv_already_moved_file_forcing_after(self):
315
309
        """Test bzr mv versioned_file to unversioned_file.
331
325
             " \(Use --after to tell bzr about a rename that has already"
332
326
             " happened\)$"],
333
327
            'mv a b')
334
 
        self.assertPathExists('a')
335
 
        self.assertPathExists('b')
 
328
        self.failUnlessExists('a')
 
329
        self.failUnlessExists('b')
336
330
 
337
331
    def test_mv_already_moved_file_using_after(self):
338
332
        """Test bzr mv --after versioned_file to unversioned_file.
352
346
        self.build_tree(['a']) #touch a
353
347
 
354
348
        self.run_bzr('mv a b --after')
355
 
        self.assertPathExists('a')
 
349
        self.failUnlessExists('a')
356
350
        self.assertNotInWorkingTree('a')#a should be unknown now.
357
 
        self.assertPathExists('b')
 
351
        self.failUnlessExists('b')
358
352
        self.assertInWorkingTree('b')
359
353
 
360
354
    def test_mv_already_moved_files_forcing_after(self):
381
375
             " exist. \(Use --after to tell bzr about a rename that has already"
382
376
             " happened\)$"],
383
377
            'mv a1 a2 sub')
384
 
        self.assertPathExists('a1')
385
 
        self.assertPathExists('a2')
386
 
        self.assertPathExists('sub/a1')
387
 
        self.assertPathExists('sub/a2')
 
378
        self.failUnlessExists('a1')
 
379
        self.failUnlessExists('a2')
 
380
        self.failUnlessExists('sub/a1')
 
381
        self.failUnlessExists('sub/a2')
388
382
 
389
383
    def test_mv_already_moved_files_using_after(self):
390
384
        """Test bzr mv --after versioned_file to directory/unversioned_file.
408
402
        self.build_tree(['a2']) #touch a2
409
403
 
410
404
        self.run_bzr('mv a1 a2 sub --after')
411
 
        self.assertPathExists('a1')
412
 
        self.assertPathExists('a2')
413
 
        self.assertPathExists('sub/a1')
414
 
        self.assertPathExists('sub/a2')
 
405
        self.failUnlessExists('a1')
 
406
        self.failUnlessExists('a2')
 
407
        self.failUnlessExists('sub/a1')
 
408
        self.failUnlessExists('sub/a2')
415
409
        self.assertInWorkingTree('sub/a1')
416
410
        self.assertInWorkingTree('sub/a2')
417
411
 
427
421
        osutils.rename('c', 'd')
428
422
        # mv a b should work just like it does for already renamed files
429
423
        self.run_bzr('mv a b')
430
 
        self.assertPathDoesNotExist('a')
 
424
        self.failIfExists('a')
431
425
        self.assertNotInWorkingTree('a')
432
 
        self.assertPathExists('b')
 
426
        self.failUnlessExists('b')
433
427
        self.assertInWorkingTree('b')
434
428
        # and --after should work, too (technically it's ignored)
435
429
        self.run_bzr('mv --after c d')
436
 
        self.assertPathDoesNotExist('c')
 
430
        self.failIfExists('c')
437
431
        self.assertNotInWorkingTree('c')
438
 
        self.assertPathExists('d')
 
432
        self.failUnlessExists('d')
439
433
        self.assertInWorkingTree('d')
440
434
 
441
435
    def make_abcd_tree(self):
510
504
        # If this fails, the tree is trying to acquire a branch lock, which it
511
505
        # shouldn't.
512
506
        self.run_bzr(['mv', 'tree/path', 'tree/path2'])
513
 
 
514
 
    def test_mv_unversioned_non_ascii(self):
515
 
        """Clear error on mv of an unversioned non-ascii file, see lp:707954"""
516
 
        self.requireFeature(UnicodeFilenameFeature)
517
 
        tree = self.make_branch_and_tree(".")
518
 
        self.build_tree([u"\xA7"])
519
 
        out, err = self.run_bzr_error(["Could not rename", "not versioned"],
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"])