126
126
tree.move, ['d', 'c', 'b'], 'a')
127
127
if osutils.lexists('a/c'):
128
128
# If 'c' was actually moved, then 'd' should have also been moved
129
self.assertTreeLayout([('', root_id), ('a', 'a-id'),
129
self.assertTreeLayout([('', root_id), ('a/', 'a-id'),
130
130
('a/c', 'c-id'), ('a/d', 'd-id')], tree)
132
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('c', 'c-id'),
132
self.assertTreeLayout([('', root_id), ('a/', 'a-id'), ('c', 'c-id'),
133
133
('d', 'd-id')], tree)
134
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('c', 'c-id'),
134
self.assertTreeLayout([('', root_id), ('a/', 'a-id'), ('c', 'c-id'),
135
135
('d', 'd-id')], tree.basis_tree())
145
145
tree.remove(['a/b'], keep_files=False)
146
146
self.assertEqual([('b', 'a/b')], tree.move(['b'], 'a'))
147
147
self.assertTreeLayout([('', root_id),
156
156
tree.add(['a', 'b', 'b/c'], ['a-id', 'b-id', 'c-id'])
157
157
tree.commit('initial', rev_id='rev-1')
158
158
root_id = tree.get_root_id()
159
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b', 'b-id'),
159
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b/', 'b-id'),
160
160
('b/c', 'c-id')], tree)
161
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b', 'b-id'),
161
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b/', 'b-id'),
162
162
('b/c', 'c-id')], tree.basis_tree())
163
163
a_contents = tree.get_file_text('a-id')
164
164
self.assertEqual([('a', 'b/a')],
165
165
tree.move(['a'], 'b'))
166
self.assertTreeLayout([('', root_id), ('b', 'b-id'), ('b/a', 'a-id'),
166
self.assertTreeLayout([('', root_id), ('b/', 'b-id'), ('b/a', 'a-id'),
167
167
('b/c', 'c-id')], tree)
168
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b', 'b-id'),
168
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b/', 'b-id'),
169
169
('b/c', 'c-id')], tree.basis_tree())
170
170
self.assertPathDoesNotExist('a')
171
171
self.assertFileEqual(a_contents, 'b/a')
180
180
c_contents = tree.get_file_text('c-id')
181
181
self.assertEqual([('b/c', 'c')],
182
182
tree.move(['b/c'], ''))
183
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b', 'b-id'),
183
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b/', 'b-id'),
184
184
('c', 'c-id')], tree)
185
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b', 'b-id'),
185
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b/', 'b-id'),
186
186
('b/c', 'c-id')], tree.basis_tree())
187
187
self.assertPathDoesNotExist('b/c')
188
188
self.assertFileEqual(c_contents, 'c')
200
200
# 'c' may or may not have been moved, but either way the tree should
201
201
# maintain a consistent state.
202
202
if osutils.lexists('c'):
203
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b', 'b-id'),
203
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b/', 'b-id'),
204
204
('c', 'c-id')], tree)
206
206
self.assertPathExists('b/c')
207
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b', 'b-id'),
207
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b/', 'b-id'),
208
208
('b/c', 'c-id')], tree)
209
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b', 'b-id'),
209
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b/', 'b-id'),
210
210
('c', 'c-id')], tree.basis_tree())
238
238
root_id = tree.get_root_id()
239
239
os.rename('a', 'b/a')
241
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b', 'b-id')],
241
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b/', 'b-id')],
243
243
# We don't need after=True as long as source is missing and target
245
245
self.assertEqual([('a', 'b/a')],
246
246
tree.move(['a'], 'b'))
247
self.assertTreeLayout([('', root_id), ('b', 'b-id'), ('b/a', 'a-id')],
247
self.assertTreeLayout([('', root_id), ('b/', 'b-id'), ('b/a', 'a-id')],
249
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b', 'b-id')],
249
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b/', 'b-id')],
250
250
tree.basis_tree())
258
258
root_id = tree.get_root_id()
259
259
os.rename('a', 'b/a')
261
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b', 'b-id')],
261
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b/', 'b-id')],
263
263
# Passing after=True should work as well
264
264
self.assertEqual([('a', 'b/a')],
265
265
tree.move(['a'], 'b', after=True))
266
self.assertTreeLayout([('', root_id), ('b', 'b-id'), ('b/a', 'a-id')],
266
self.assertTreeLayout([('', root_id), ('b/', 'b-id'), ('b/a', 'a-id')],
268
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b', 'b-id')],
268
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b/', 'b-id')],
269
269
tree.basis_tree())
279
279
# Passing after when the file hasn't been move raises an exception
280
280
self.assertRaises(errors.BzrMoveFailedError,
281
281
tree.move, ['a'], 'b', after=True)
282
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b', 'b-id')],
282
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b/', 'b-id')],
283
283
tree.basis_tree())
306
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b', 'b-id')],
306
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b/', 'b-id')],
308
308
self.assertRaises(errors.RenameFailedFilesExist,
309
309
tree.move, ['a'], 'b', after=False)
310
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b', 'b-id')],
310
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b/', 'b-id')],
312
312
self.assertFileEqual(a_text, 'a')
313
313
self.assertFileEqual(ba_text, 'b/a')
314
314
# But you can pass after=True
315
315
self.assertEqual([('a', 'b/a')],
316
316
tree.move(['a'], 'b', after=True))
317
self.assertTreeLayout([('', root_id), ('b', 'b-id'), ('b/a', 'a-id')],
317
self.assertTreeLayout([('', root_id), ('b/', 'b-id'), ('b/a', 'a-id')],
319
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b', 'b-id')],
319
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b/', 'b-id')],
320
320
tree.basis_tree())
321
321
# But it shouldn't actually move anything
322
322
self.assertFileEqual(a_text, 'a')
334
334
self.assertEqual([('a', 'e/a')],
335
335
tree.move(['a'], 'e'))
336
self.assertTreeLayout([('', root_id), ('e', 'e-id'), ('e/a', 'a-id'),
337
('e/a/b', 'b-id'), ('e/a/c', 'c-id'),
336
self.assertTreeLayout([('', root_id), ('e/', 'e-id'), ('e/a/', 'a-id'),
337
('e/a/b', 'b-id'), ('e/a/c/', 'c-id'),
338
338
('e/a/c/d', 'd-id')], tree)
339
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('e', 'e-id'),
340
('a/b', 'b-id'), ('a/c', 'c-id'),
339
self.assertTreeLayout([('', root_id), ('a/', 'a-id'), ('e/', 'e-id'),
340
('a/b', 'b-id'), ('a/c/', 'c-id'),
341
341
('a/c/d', 'd-id')], tree.basis_tree())
370
370
root_id = tree.get_root_id()
372
372
tree.rename_one('a/b', 'a/c/b')
373
if self.workingtree_format.supports_versioned_directories:
374
self.assertTreeLayout([('', root_id),
381
self.assertTreeLayout([('', root_id),
373
self.assertTreeLayout([('', root_id),
386
379
self.assertEqual([('a', 'd/a')],
387
380
tree.move(['a'], 'd'))
388
381
self.assertTreeLayout([('', root_id),
392
385
('d/a/c/b', 'b-id'),
444
437
self.assertEqual([('a/b', 'b')],
445
438
tree.move(['a/b'], ''))
446
439
self.assertTreeLayout([('', root_id),
453
446
self.assertEqual([('d', 'a/d')],
454
447
tree.move(['d'], 'a'))
455
448
self.assertTreeLayout([('', root_id),
481
474
tree.rename_one('a/b', 'a/d')
482
475
self.assertTreeLayout([('', root_id),
488
481
self.assertEqual([('a', 'd/a')],
489
482
tree.move(['a'], 'd'))
490
483
self.assertTreeLayout([('', root_id),
493
486
('d/a/c', 'c-id'),
494
487
('d/a/d', 'b-id'),
535
528
self.assertEqual([('a/b', 'c/b')],
536
529
tree.move(['a/b'], 'c'))
537
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('c', 'c-id'),
530
self.assertTreeLayout([('', root_id), ('a/', 'a-id'), ('c/', 'c-id'),
538
531
('c/b', 'b-id')], tree)
539
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('c', 'c-id'),
532
self.assertTreeLayout([('', root_id), ('a/', 'a-id'), ('c/', 'c-id'),
540
533
('a/b', 'b-id')], tree.basis_tree())
542
535
self.assertEqual([('c/b', 'b')],
543
536
tree.move(['c/b'], ''))
544
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('b', 'b-id'),
545
('c', 'c-id')], tree)
546
self.assertTreeLayout([('', root_id), ('a', 'a-id'), ('c', 'c-id'),
537
self.assertTreeLayout([('', root_id), ('a/', 'a-id'), ('b', 'b-id'),
538
('c/', 'c-id')], tree)
539
self.assertTreeLayout([('', root_id), ('a/', 'a-id'), ('c/', 'c-id'),
547
540
('a/b', 'b-id')], tree.basis_tree())