~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Vincent Ladeuil
  • Date: 2007-06-26 20:32:49 UTC
  • mto: (2581.1.1 cleanup-runbzr)
  • mto: This revision was merged to the branch mainline in revision 2588.
  • Revision ID: v.ladeuil+lp@free.fr-20070626203249-sqm4afiai5dxofum
Deprecate the varargs syntax and fix the tests.

* bzrlib/tests/__init__.py:
(TestCase.run_bzr): Activate the deprecation warning.
(TestCase.run_bzr_error): Add error_regexes to kwargs or run_bzr
get confused.

* bzrlib/tests/blackbox/test_selftest.py:
(TestRunBzr.test_args): Activate.

* bzrlib/tests/blackbox/test_inventory.py:
(TestInventory.assertInventoryEqual): Build the command from args
if not None.

* bzrlib/tests/blackbox/test_ls.py:
(TestLS.ls_equals): Build the command from args if not None.

* bzrlib/tests/blackbox/test_remove_tree.py:
(TestRemoveTree.test_remove_tree_lightweight_checkout_explicit):
Nice catch, we were calling run_bzr instead of run_bzr_error. This
went unnoticed for some time...

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
        files = self.build_tree(['a', 'c', 'subdir/'])
46
46
        tree.add(['a', 'c', 'subdir'])
47
47
 
48
 
        self.run_bzr('mv', 'a', 'b')
 
48
        self.run_bzr('mv a b')
49
49
        self.assertMoved('a','b')
50
50
 
51
 
        self.run_bzr('mv', 'b', 'subdir')
 
51
        self.run_bzr('mv b subdir')
52
52
        self.assertMoved('b','subdir/b')
53
53
 
54
 
        self.run_bzr('mv', 'subdir/b', 'a')
 
54
        self.run_bzr('mv subdir/b a')
55
55
        self.assertMoved('subdir/b','a')
56
56
 
57
 
        self.run_bzr('mv', 'a', 'c', 'subdir')
 
57
        self.run_bzr('mv a c subdir')
58
58
        self.assertMoved('a','subdir/a')
59
59
        self.assertMoved('c','subdir/c')
60
60
 
61
 
        self.run_bzr('mv', 'subdir/a', 'subdir/newa')
 
61
        self.run_bzr('mv subdir/a subdir/newa')
62
62
        self.assertMoved('subdir/a','subdir/newa')
63
63
 
64
64
    def test_mv_unversioned(self):
66
66
        self.run_bzr_error(
67
67
            ["^bzr: ERROR: Could not rename unversioned.txt => elsewhere."
68
68
             " .*unversioned.txt is not versioned$"],
69
 
            'mv', 'unversioned.txt', 'elsewhere')
 
69
            'mv unversioned.txt elsewhere')
70
70
 
71
71
    def test_mv_nonexisting(self):
72
72
        self.run_bzr_error(
73
73
            ["^bzr: ERROR: Could not rename doesnotexist => somewhereelse."
74
74
             " .*doesnotexist is not versioned$"],
75
 
            'mv', 'doesnotexist', 'somewhereelse')
 
75
            'mv doesnotexist somewhereelse')
76
76
 
77
77
    def test_mv_unqualified(self):
78
78
        self.run_bzr_error(['^bzr: ERROR: missing file argument$'], 'mv')
84
84
 
85
85
        self.run_bzr_error(
86
86
            ["^bzr: ERROR: Could not move to sub1: sub1 is not versioned$"],
87
 
            'mv', 'test.txt', 'sub1')
 
87
            'mv test.txt sub1')
88
88
 
89
89
        self.run_bzr_error(
90
90
            ["^bzr: ERROR: Could not move test.txt => .*hello.txt: "
91
91
             "sub1 is not versioned$"],
92
 
            'mv', 'test.txt', 'sub1/hello.txt')
 
92
            'mv test.txt sub1/hello.txt')
93
93
        
94
94
    def test_mv_dirs(self):
95
95
        tree = self.make_branch_and_tree('.')
96
96
        self.build_tree(['hello.txt', 'sub1/'])
97
97
        tree.add(['hello.txt', 'sub1'])
98
98
 
99
 
        self.run_bzr('mv', 'sub1', 'sub2')
 
99
        self.run_bzr('mv sub1 sub2')
100
100
        self.assertMoved('sub1','sub2')
101
101
 
102
 
        self.run_bzr('mv', 'hello.txt', 'sub2')
 
102
        self.run_bzr('mv hello.txt sub2')
103
103
        self.assertMoved('hello.txt','sub2/hello.txt')
104
104
 
105
105
        self.build_tree(['sub1/'])
106
106
        tree.add(['sub1'])
107
 
        self.run_bzr('mv', 'sub2/hello.txt', 'sub1')
 
107
        self.run_bzr('mv sub2/hello.txt sub1')
108
108
        self.assertMoved('sub2/hello.txt','sub1/hello.txt')
109
109
 
110
 
        self.run_bzr('mv', 'sub2', 'sub1')
 
110
        self.run_bzr('mv sub2 sub1')
111
111
        self.assertMoved('sub2','sub1/sub2')
112
112
 
113
113
    def test_mv_relative(self):
116
116
        tree.add(['sub1', 'sub1/sub2', 'sub1/hello.txt'])
117
117
 
118
118
        os.chdir('sub1/sub2')
119
 
        self.run_bzr('mv', '../hello.txt', '.')
 
119
        self.run_bzr('mv ../hello.txt .')
120
120
        self.failUnlessExists('./hello.txt')
121
121
 
122
122
        os.chdir('..')
123
 
        self.run_bzr('mv', 'sub2/hello.txt', '.')
 
123
        self.run_bzr('mv sub2/hello.txt .')
124
124
        os.chdir('..')
125
125
        self.assertMoved('sub1/sub2/hello.txt','sub1/hello.txt')
126
126
 
131
131
        tree = self.make_branch_and_tree('.')
132
132
        tree.add(['a'])
133
133
 
134
 
        self.run_bzr('move', 'a', 'b')
135
 
        self.run_bzr('rename', 'b', 'a')
 
134
        self.run_bzr('move a b')
 
135
        self.run_bzr('rename b a')
136
136
 
137
137
    def test_mv_through_symlinks(self):
138
138
        if not osutils.has_symlinks():
142
142
        os.symlink('a', 'c')
143
143
        os.symlink('.', 'd')
144
144
        tree.add(['a', 'a/b', 'c'], ['a-id', 'b-id', 'c-id'])
145
 
        self.run_bzr('mv', 'c/b', 'b')
 
145
        self.run_bzr('mv c/b b')
146
146
        tree = workingtree.WorkingTree.open('.')
147
147
        self.assertEqual('b-id', tree.path2id('b'))
148
148
 
159
159
        tree.add(['a'])
160
160
 
161
161
        osutils.rename('a', 'b')
162
 
        self.run_bzr('mv', 'a', 'b')
 
162
        self.run_bzr('mv a b')
163
163
        self.assertMoved('a','b')
164
164
 
165
165
    def test_mv_already_moved_file_to_versioned_target(self):
178
178
        osutils.rename('a', 'b')
179
179
        self.run_bzr_error(
180
180
            ["^bzr: ERROR: Could not move a => b. b is already versioned$"],
181
 
            'mv', 'a', 'b')
 
181
            'mv a b')
182
182
        #check that nothing changed
183
183
        self.failIfExists('a')
184
184
        self.failUnlessExists('b')
196
196
        tree.add(['a', 'sub'])
197
197
 
198
198
        osutils.rename('a', 'sub/a')
199
 
        self.run_bzr('mv', 'a', 'sub/a')
 
199
        self.run_bzr('mv a sub/a')
200
200
        self.assertMoved('a','sub/a')
201
201
 
202
202
    def test_mv_already_moved_file_into_unversioned_subdir(self):
214
214
        osutils.rename('a', 'sub/a')
215
215
        self.run_bzr_error(
216
216
            ["^bzr: ERROR: Could not move a => a: sub is not versioned$"],
217
 
            'mv', 'a', 'sub/a')
 
217
            'mv a sub/a')
218
218
        self.failIfExists('a')
219
219
        self.failUnlessExists('sub/a')
220
220
 
231
231
        tree.add(['a1', 'a2', 'sub'])
232
232
 
233
233
        osutils.rename('a1', 'sub/a1')
234
 
        self.run_bzr('mv', 'a1', 'a2', 'sub')
 
234
        self.run_bzr('mv a1 a2 sub')
235
235
        self.assertMoved('a1','sub/a1')
236
236
        self.assertMoved('a2','sub/a2')
237
237
 
250
250
        osutils.rename('a1', 'sub/a1')
251
251
        self.run_bzr_error(
252
252
            ["^bzr: ERROR: Could not move to sub. sub is not versioned$"],
253
 
            'mv', 'a1', 'a2', 'sub')
 
253
            'mv a1 a2 sub')
254
254
        self.failIfExists('a1')
255
255
        self.failUnlessExists('sub/a1')
256
256
        self.failUnlessExists('a2')
274
274
        self.run_bzr_error(
275
275
            ["^bzr: ERROR: Could not rename a => b because both files exist."
276
276
             " \(Use --after to update the Bazaar id\)$"],
277
 
            'mv', 'a', 'b')
 
277
            'mv a b')
278
278
        self.failUnlessExists('a')
279
279
        self.failUnlessExists('b')
280
280
 
295
295
        osutils.rename('a', 'b')
296
296
        self.build_tree(['a']) #touch a
297
297
 
298
 
        self.run_bzr('mv', 'a', 'b', '--after')
 
298
        self.run_bzr('mv a b --after')
299
299
        self.failUnlessExists('a')
300
300
        self.assertNotInWorkingTree('a')#a should be unknown now.
301
301
        self.failUnlessExists('b')
323
323
        self.run_bzr_error(
324
324
            ["^bzr: ERROR: Could not rename a1 => sub/a1 because both files exist."
325
325
             " \(Use --after to update the Bazaar id\)$"],
326
 
            'mv', 'a1', 'a2', 'sub')
 
326
            'mv a1 a2 sub')
327
327
        self.failUnlessExists('a1')
328
328
        self.failUnlessExists('a2')
329
329
        self.failUnlessExists('sub/a1')
350
350
        self.build_tree(['a1']) #touch a1
351
351
        self.build_tree(['a2']) #touch a2
352
352
 
353
 
        self.run_bzr('mv', 'a1', 'a2', 'sub', '--after')
 
353
        self.run_bzr('mv a1 a2 sub --after')
354
354
        self.failUnlessExists('a1')
355
355
        self.failUnlessExists('a2')
356
356
        self.failUnlessExists('sub/a1')