~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Marius Kruger
  • Date: 2007-01-03 06:14:43 UTC
  • mfrom: (2206.1.10 bzr.enhanced_move)
  • mto: This revision was merged to the branch mainline in revision 2241.
  • Revision ID: amanic@gmail.com-20070103061443-i6kogbeqb54148p9
merge enhancedmv3.patch with bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
    TestCaseWithTransport,
27
27
    TestSkipped,
28
28
    )
29
 
 
 
29
from bzrlib.osutils import (
 
30
    splitpath
 
31
    )
30
32
 
31
33
class TestMove(TestCaseWithTransport):
32
34
 
61
63
    def test_mv_unversioned(self):
62
64
        self.build_tree(['unversioned.txt'])
63
65
        self.run_bzr_error(
64
 
            ["^bzr: ERROR: can't rename: old name .* is not versioned$"],
 
66
            ["^bzr: ERROR: Could not rename unversioned.txt => elsewhere."
 
67
             " .*unversioned.txt is not versioned$"],
65
68
            'mv', 'unversioned.txt', 'elsewhere')
66
69
 
67
70
    def test_mv_nonexisting(self):
68
71
        self.run_bzr_error(
69
 
            ["^bzr: ERROR: can't rename: old working file .* does not exist$"],
 
72
            ["^bzr: ERROR: Could not rename doesnotexist => somewhereelse."
 
73
             " .*doesnotexist is not versioned$"],
70
74
            'mv', 'doesnotexist', 'somewhereelse')
71
75
 
72
76
    def test_mv_unqualified(self):
78
82
        tree.add(['test.txt'])
79
83
 
80
84
        self.run_bzr_error(
81
 
            ["^bzr: ERROR: destination u'sub1' is not a versioned directory$"],
 
85
            ["^bzr: ERROR: Could not move to sub1: sub1 is not versioned$"],
82
86
            'mv', 'test.txt', 'sub1')
83
 
        
 
87
 
84
88
        self.run_bzr_error(
85
 
            ["^bzr: ERROR: can't determine destination directory id for u'sub1'$"],
 
89
            ["^bzr: ERROR: Could not move test.txt => .*hello.txt: "
 
90
             "sub1 is not versioned$"],
86
91
            'mv', 'test.txt', 'sub1/hello.txt')
87
92
        
88
93
    def test_mv_dirs(self):
147
152
        self.run_bzr('mv', 'c/b', 'b')
148
153
        tree = workingtree.WorkingTree.open('.')
149
154
        self.assertEqual('b-id', tree.path2id('b'))
 
155
 
 
156
    def test_mv_already_moved_file(self):
 
157
        """a is in repository, b does not exist. User does
 
158
        mv a b; bzr mv a b"""
 
159
        self.build_tree(['a', 'b'])
 
160
        tree = self.make_branch_and_tree('.')
 
161
        tree.add(['a'])
 
162
        tree.commit('initial commit')
 
163
 
 
164
        os.rename('a', 'b')
 
165
        self.run_bzr('mv', 'a', 'b')
 
166
        self.failIfExists('a')
 
167
        self.failUnlessExists('b')
 
168
 
 
169
    def test_mv_already_moved_file_to_versioned_target(self):
 
170
        """a and b are in the repository. User does
 
171
        rm b; mv a b; bzr mv a b"""
 
172
        self.build_tree(['a', 'b'])
 
173
        tree = self.make_branch_and_tree('.')
 
174
        tree.add(['a', 'b'])
 
175
        tree.commit('initial commit')
 
176
    
 
177
        os.remove('a')
 
178
        self.run_bzr_error(
 
179
            ["^bzr: ERROR: Could not move a => b. b is already versioned$"],
 
180
            'mv', 'a', 'b')
 
181
        self.failIfExists('a')
 
182
        self.failUnlessExists('b')
 
183
 
 
184
    def test_mv_already_moved_file_into_subdir(self):
 
185
        """a and sub1/ are in the repository. User does
 
186
        mv a sub1/a; bzr mv a sub1/a"""
 
187
        self.build_tree(['a', 'sub1/'])
 
188
        tree = self.make_branch_and_tree('.')
 
189
        tree.add(['a', 'sub1'])
 
190
        tree.commit('initial commit')
 
191
        
 
192
        os.rename('a', 'sub1/a')
 
193
        self.run_bzr('mv', 'a', 'sub1/a')
 
194
        self.failIfExists('a')
 
195
        self.failUnlessExists('sub1/a')
 
196
 
 
197
    def test_mv_already_moved_file_into_unversioned_subdir(self):
 
198
        """a is in the repository, sub1/ is not. User does
 
199
        mv a sub1/a; bzr mv a sub1/a"""
 
200
        self.build_tree(['a', 'sub1/'])
 
201
        tree = self.make_branch_and_tree('.')
 
202
        tree.add(['a'])
 
203
        tree.commit('initial commit')
 
204
 
 
205
        os.rename('a', 'sub1/a')
 
206
        self.run_bzr_error(
 
207
            ["^bzr: ERROR: Could not move a => a: sub1 is not versioned$"],
 
208
            'mv', 'a', 'sub1/a')
 
209
        self.failIfExists('a')
 
210
        self.failUnlessExists('sub1/a')
 
211
 
 
212
    def test_mv_already_moved_files_into_subdir(self):
 
213
        """a1, a2, sub1 are in the repository. User does
 
214
        mv a1 sub1/.; bzr mv a1 a2 sub1"""
 
215
        self.build_tree(['a1', 'a2', 'sub1/'])
 
216
        tree = self.make_branch_and_tree('.')
 
217
        tree.add(['a1', 'a2', 'sub1'])
 
218
        tree.commit('initial commit')
 
219
 
 
220
        os.rename('a1', 'sub1/a1')
 
221
        self.run_bzr('mv', 'a1', 'a2', 'sub1')
 
222
        self.failIfExists('a1')
 
223
        self.failIfExists('a2')
 
224
        self.failUnlessExists('sub1/a1')
 
225
        self.failUnlessExists('sub1/a2')
 
226
        
 
227
    def test_mv_already_moved_files_into_unversioned_subdir(self):
 
228
        """a1, a2 are in the repository, sub1 is not. User does
 
229
        mv a1 sub1/.; bzr mv a1 a2 sub1"""
 
230
        self.build_tree(['a1', 'a2', 'sub1/'])
 
231
        tree = self.make_branch_and_tree('.')
 
232
        tree.add(['a1', 'a2'])
 
233
        tree.commit('initial commit')
 
234
 
 
235
        os.rename('a1', 'sub1/a1')
 
236
        self.run_bzr_error(
 
237
            ["^bzr: ERROR: Could not move to sub1. sub1 is not versioned$"],
 
238
            'mv', 'a1', 'a2', 'sub1')
 
239
        self.failIfExists('a1')
 
240
        self.failUnlessExists('a2')
 
241
        self.failUnlessExists('sub1/a1')
 
242
        self.failIfExists('sub1/a2')
 
243
 
 
244
    def test_mv_already_moved_file_forcing_after(self):
 
245
        """a is in the repository, b does not exist. User does
 
246
        mv a b; touch a; bzr mv a b"""
 
247
        self.build_tree(['a', 'b'])
 
248
        tree = self.make_branch_and_tree('.')
 
249
        tree.add(['a'])
 
250
        tree.commit('initial commit')
 
251
 
 
252
        self.run_bzr_error(
 
253
            ["^bzr: ERROR: Could not rename a => b: Files exist: a b:"
 
254
             " \(Use option '--after' to force rename\)$"],
 
255
            'mv', 'a', 'b')
 
256
        self.failUnlessExists('a')
 
257
        self.failUnlessExists('b')
 
258
 
 
259
    def test_mv_already_moved_file_using_after(self):
 
260
        """a is in the repository, b does not exist. User does
 
261
        mv a b; touch a; bzr mv a b --after"""
 
262
        self.build_tree(['a', 'b'])
 
263
        tree = self.make_branch_and_tree('.')
 
264
        tree.add(['a'])
 
265
        tree.commit('initial commit')
 
266
 
 
267
        self.run_bzr('mv', 'a', 'b', '--after')
 
268
        self.failUnlessExists('a')
 
269
        self.failUnlessExists('b')
 
270
 
 
271
    def test_mv_already_moved_files_forcing_after(self):
 
272
        """a1, a2, sub1 are in the repository, sub1/a1, sub1/a2
 
273
        do not exist. User does
 
274
        mv a* sub1; touch a1; touch a2; bzr mv a1 a2 sub1"""
 
275
        self.build_tree(['a1', 'a2', 'sub1/', 'sub1/a1', 'sub1/a2'])
 
276
        tree = self.make_branch_and_tree('.')
 
277
        tree.add(['a1', 'a2', 'sub1'])
 
278
        tree.commit('initial commit')
 
279
 
 
280
        self.run_bzr_error(
 
281
            ["^bzr: ERROR: Could not rename a1 => a1: Files exist: a1 .*a1:"
 
282
             " \(Use option '--after' to force rename\)$"],
 
283
            'mv', 'a1', 'a2', 'sub1')
 
284
        self.failUnlessExists('a1')
 
285
        self.failUnlessExists('a2')
 
286
        self.failUnlessExists('sub1/a1')
 
287
        self.failUnlessExists('sub1/a2')
 
288
        
 
289
    def test_mv_already_moved_files_using_after(self):
 
290
        """a1, a2, sub1 are in the repository, sub1/a1, sub1/a2
 
291
        do not exist. User does
 
292
        mv a* sub1; touch a1; touch a2; bzr mv a1 a2 sub1 --after"""
 
293
        self.build_tree(['a1', 'a2', 'sub1/', 'sub1/a1', 'sub1/a2'])
 
294
        tree = self.make_branch_and_tree('.')
 
295
        tree.add(['a1', 'a2', 'sub1'])
 
296
        tree.commit('initial commit')
 
297
 
 
298
        self.run_bzr('mv', 'a1', 'a2', 'sub1', '--after')
 
299
        self.failUnlessExists('a1')
 
300
        self.failUnlessExists('a2')
 
301
        self.failUnlessExists('sub1/a1')
 
302
        self.failUnlessExists('sub1/a2')