147
152
self.run_bzr('mv', 'c/b', 'b')
148
153
tree = workingtree.WorkingTree.open('.')
149
154
self.assertEqual('b-id', tree.path2id('b'))
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('.')
162
tree.commit('initial commit')
165
self.run_bzr('mv', 'a', 'b')
166
self.failIfExists('a')
167
self.failUnlessExists('b')
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('.')
175
tree.commit('initial commit')
179
["^bzr: ERROR: Could not move a => b. b is already versioned$"],
181
self.failIfExists('a')
182
self.failUnlessExists('b')
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')
192
os.rename('a', 'sub1/a')
193
self.run_bzr('mv', 'a', 'sub1/a')
194
self.failIfExists('a')
195
self.failUnlessExists('sub1/a')
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('.')
203
tree.commit('initial commit')
205
os.rename('a', 'sub1/a')
207
["^bzr: ERROR: Could not move a => a: sub1 is not versioned$"],
209
self.failIfExists('a')
210
self.failUnlessExists('sub1/a')
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')
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')
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')
235
os.rename('a1', 'sub1/a1')
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')
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('.')
250
tree.commit('initial commit')
253
["^bzr: ERROR: Could not rename a => b: Files exist: a b:"
254
" \(Use option '--after' to force rename\)$"],
256
self.failUnlessExists('a')
257
self.failUnlessExists('b')
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('.')
265
tree.commit('initial commit')
267
self.run_bzr('mv', 'a', 'b', '--after')
268
self.failUnlessExists('a')
269
self.failUnlessExists('b')
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')
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')
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')
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')