~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: John Arbash Meinel
  • Date: 2010-02-10 17:52:08 UTC
  • mfrom: (5021 +trunk)
  • mto: This revision was merged to the branch mainline in revision 5023.
  • Revision ID: john@arbash-meinel.com-20100210175208-bubuwav4uqigu291
Merge bzr.dev 5021 to resolve NEWS

Show diffs side-by-side

added added

removed removed

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