36
36
def get_transform(self):
37
37
transform = TreeTransform(self.wt)
38
38
#self.addCleanup(transform.finalize)
39
return transform, transform.get_id_tree(self.wt.get_root_id())
39
return transform, transform.trans_id_tree_file_id(self.wt.get_root_id())
41
41
def test_existing_limbo(self):
42
42
limbo_name = self.wt._control_files.controlfilename('limbo')
54
54
def test_build(self):
55
55
transform, root = self.get_transform()
56
56
self.assertIs(transform.get_tree_parent(root), ROOT_PARENT)
57
imaginary_id = transform.get_tree_path_id('imaginary')
57
imaginary_id = transform.trans_id_tree_path('imaginary')
58
58
self.assertEqual(transform.get_tree_parent(imaginary_id), root)
59
59
self.assertEqual(transform.final_kind(root), 'directory')
60
60
self.assertEqual(transform.final_file_id(root), self.wt.get_root_id())
122
122
transform.adjust_path('name', trans_id, trans_id2)
123
123
self.assertEqual(transform.find_conflicts(),
124
124
[('non-directory parent', trans_id)])
125
tinman_id = transform.get_tree_path_id('tinman')
125
tinman_id = transform.trans_id_tree_path('tinman')
126
126
transform.adjust_path('name', tinman_id, trans_id2)
127
127
self.assertEqual(transform.find_conflicts(),
128
128
[('unversioned parent', tinman_id),
161
161
self.assertEqual(self.wt.path2id('name'), 'my_pretties')
162
162
self.assertEqual('contents', file(self.wt.abspath('name')).read())
163
163
transform2, root = self.get_transform()
164
oz_id = transform2.get_id_tree('oz-id')
164
oz_id = transform2.trans_id_tree_file_id('oz-id')
165
165
newtip = transform2.new_file('tip', oz_id, 'other', 'tip-id')
166
166
result = transform2.find_conflicts()
167
167
fp = FinalPaths(transform2)
175
175
transform2.finalize()
176
176
transform3 = TreeTransform(self.wt)
177
177
self.addCleanup(transform3.finalize)
178
oz_id = transform3.get_id_tree('oz-id')
178
oz_id = transform3.trans_id_tree_file_id('oz-id')
179
179
transform3.delete_contents(oz_id)
180
180
self.assertEqual(transform3.find_conflicts(),
181
181
[('missing parent', oz_id)])
182
root_id = transform3.get_id_tree('TREE_ROOT')
183
tip_id = transform3.get_id_tree('tip-id')
182
root_id = transform3.trans_id_tree_file_id('TREE_ROOT')
183
tip_id = transform3.trans_id_tree_file_id('tip-id')
184
184
transform3.adjust_path('tip', root_id, tip_id)
185
185
transform3.apply()
191
191
create_tree.apply()
192
192
unversion = TreeTransform(self.wt)
193
193
self.addCleanup(unversion.finalize)
194
parent = unversion.get_tree_path_id('parent')
194
parent = unversion.trans_id_tree_path('parent')
195
195
unversion.unversion_file(parent)
196
196
self.assertEqual(unversion.find_conflicts(),
197
197
[('unversioned parent', parent_id)])
198
file_id = unversion.get_id_tree('child-id')
198
file_id = unversion.trans_id_tree_file_id('child-id')
199
199
unversion.unversion_file(file_id)
200
200
unversion.apply()
202
202
def test_name_invariants(self):
203
203
create_tree, root = self.get_transform()
205
root = create_tree.get_id_tree('TREE_ROOT')
205
root = create_tree.trans_id_tree_file_id('TREE_ROOT')
206
206
create_tree.new_file('name1', root, 'hello1', 'name1')
207
207
create_tree.new_file('name2', root, 'hello2', 'name2')
208
208
ddir = create_tree.new_directory('dying_directory', root, 'ddir')
212
212
create_tree.apply()
214
214
mangle_tree,root = self.get_transform()
215
root = mangle_tree.get_id_tree('TREE_ROOT')
215
root = mangle_tree.trans_id_tree_file_id('TREE_ROOT')
217
name1 = mangle_tree.get_id_tree('name1')
218
name2 = mangle_tree.get_id_tree('name2')
217
name1 = mangle_tree.trans_id_tree_file_id('name1')
218
name2 = mangle_tree.trans_id_tree_file_id('name2')
219
219
mangle_tree.adjust_path('name2', root, name1)
220
220
mangle_tree.adjust_path('name1', root, name2)
222
222
#tests for deleting parent directories
223
ddir = mangle_tree.get_id_tree('ddir')
223
ddir = mangle_tree.trans_id_tree_file_id('ddir')
224
224
mangle_tree.delete_contents(ddir)
225
dfile = mangle_tree.get_id_tree('dfile')
225
dfile = mangle_tree.trans_id_tree_file_id('dfile')
226
226
mangle_tree.delete_versioned(dfile)
227
227
mangle_tree.unversion_file(dfile)
228
mfile = mangle_tree.get_id_tree('mfile')
228
mfile = mangle_tree.trans_id_tree_file_id('mfile')
229
229
mangle_tree.adjust_path('mfile', root, mfile)
231
231
#tests for adding parent directories
232
232
newdir = mangle_tree.new_directory('new_directory', root, 'newdir')
233
mfile2 = mangle_tree.get_id_tree('mfile2')
233
mfile2 = mangle_tree.trans_id_tree_file_id('mfile2')
234
234
mangle_tree.adjust_path('mfile2', newdir, mfile2)
235
235
mangle_tree.new_file('newfile', newdir, 'hello3', 'dfile')
236
236
self.assertEqual(mangle_tree.final_file_id(mfile2), 'mfile2')
256
256
create_tree.new_file('blackbox.py', newdir, 'hello1', 'blackbox-id')
257
257
create_tree.apply()
258
258
mangle_tree,root = self.get_transform()
259
selftest = mangle_tree.get_id_tree('selftest-id')
260
blackbox = mangle_tree.get_id_tree('blackbox-id')
259
selftest = mangle_tree.trans_id_tree_file_id('selftest-id')
260
blackbox = mangle_tree.trans_id_tree_file_id('blackbox-id')
261
261
mangle_tree.adjust_path('test', root, selftest)
262
262
mangle_tree.adjust_path('test_too_much', root, selftest)
263
263
mangle_tree.set_executability(True, blackbox)
272
272
'test_too_much-id')
273
273
create_tree.apply()
274
274
mangle_tree,root = self.get_transform()
275
bzrlib = mangle_tree.get_id_tree('bzrlib-id')
276
tests = mangle_tree.get_id_tree('tests-id')
277
test_too_much = mangle_tree.get_id_tree('test_too_much-id')
275
bzrlib = mangle_tree.trans_id_tree_file_id('bzrlib-id')
276
tests = mangle_tree.trans_id_tree_file_id('tests-id')
277
test_too_much = mangle_tree.trans_id_tree_file_id('test_too_much-id')
278
278
mangle_tree.adjust_path('selftest', bzrlib, tests)
279
279
mangle_tree.adjust_path('blackbox.py', tests, test_too_much)
280
280
mangle_tree.set_executability(True, test_too_much)
287
287
'test_too_much-id')
288
288
create_tree.apply()
289
289
mangle_tree,root = self.get_transform()
290
tests = mangle_tree.get_id_tree('tests-id')
291
test_too_much = mangle_tree.get_id_tree('test_too_much-id')
290
tests = mangle_tree.trans_id_tree_file_id('tests-id')
291
test_too_much = mangle_tree.trans_id_tree_file_id('test_too_much-id')
292
292
mangle_tree.adjust_path('selftest', root, tests)
293
293
mangle_tree.adjust_path('blackbox.py', tests, test_too_much)
294
294
mangle_tree.set_executability(True, test_too_much)
297
297
def test_move_dangling_ie(self):
298
298
create_tree, root = self.get_transform()
300
root = create_tree.get_id_tree('TREE_ROOT')
300
root = create_tree.trans_id_tree_file_id('TREE_ROOT')
301
301
create_tree.new_file('name1', root, 'hello1', 'name1')
302
302
create_tree.apply()
303
303
delete_contents, root = self.get_transform()
304
file = delete_contents.get_id_tree('name1')
304
file = delete_contents.trans_id_tree_file_id('name1')
305
305
delete_contents.delete_contents(file)
306
306
delete_contents.apply()
307
307
move_id, root = self.get_transform()
308
name1 = move_id.get_id_tree('name1')
308
name1 = move_id.trans_id_tree_file_id('name1')
309
309
newdir = move_id.new_directory('dir', root, 'newdir')
310
310
move_id.adjust_path('name2', newdir, name1)
313
313
def test_replace_dangling_ie(self):
314
314
create_tree, root = self.get_transform()
316
root = create_tree.get_id_tree('TREE_ROOT')
316
root = create_tree.trans_id_tree_file_id('TREE_ROOT')
317
317
create_tree.new_file('name1', root, 'hello1', 'name1')
318
318
create_tree.apply()
319
319
delete_contents = TreeTransform(self.wt)
320
320
self.addCleanup(delete_contents.finalize)
321
file = delete_contents.get_id_tree('name1')
321
file = delete_contents.trans_id_tree_file_id('name1')
322
322
delete_contents.delete_contents(file)
323
323
delete_contents.apply()
324
324
delete_contents.finalize()
326
326
self.addCleanup(replace.finalize)
327
327
name2 = replace.new_file('name2', root, 'hello2', 'name1')
328
328
conflicts = replace.find_conflicts()
329
name1 = replace.get_id_tree('name1')
329
name1 = replace.trans_id_tree_file_id('name1')
330
330
self.assertEqual(conflicts, [('duplicate id', name1, name2)])
331
331
resolve_conflicts(replace)
364
364
# set up duplicate entry, duplicate id
365
365
new_dorothy = conflicts.new_file('dorothy', root, 'dorothy',
367
old_dorothy = conflicts.get_id_tree('dorothy-id')
368
oz = conflicts.get_id_tree('oz-id')
367
old_dorothy = conflicts.trans_id_tree_file_id('dorothy-id')
368
oz = conflicts.trans_id_tree_file_id('oz-id')
369
369
# set up missing, unversioned parent
370
370
conflicts.delete_versioned(oz)
371
emerald = conflicts.get_id_tree('emerald-id')
371
emerald = conflicts.trans_id_tree_file_id('emerald-id')
372
372
# set up parent loop
373
373
conflicts.adjust_path('emeraldcity', emerald, emerald)
374
374
return conflicts, emerald, oz, old_dorothy, new_dorothy
432
432
create.new_directory('oz', root, 'oz-id')
434
434
cyclone, root = self.get_transform()
435
oz = cyclone.get_id_tree('oz-id')
436
house = cyclone.get_id_tree('house-id')
435
oz = cyclone.trans_id_tree_file_id('oz-id')
436
house = cyclone.trans_id_tree_file_id('house-id')
437
437
cyclone.adjust_path('house', oz, house)
446
446
transform, root = self.get_transform()
447
447
transform.adjust_root_path('oldroot', fun)
448
new_root=transform.get_tree_path_id('')
448
new_root=transform.trans_id_tree_path('')
449
449
transform.version_file('new-root', new_root)
450
450
transform.apply()
459
459
rename, root = self.get_transform()
460
old = rename.get_trans_id('old-id')
460
old = rename.trans_id_file_id('old-id')
461
461
rename.adjust_path('new', root, old)
462
myfile = rename.get_trans_id('myfile-id')
462
myfile = rename.trans_id_file_id('myfile-id')
463
463
rename.set_executability(True, myfile)
482
482
self.b = Branch.initialize(dirname)
483
483
self.wt = self.b.working_tree()
484
484
self.tt = TreeTransform(self.wt)
485
self.root = self.tt.get_id_tree(self.wt.get_root_id())
485
self.root = self.tt.trans_id_tree_file_id(self.wt.get_root_id())
487
487
def conflict_text(tree, merge):
488
488
template = '%s TREE\n%s%s\n%s%s MERGE-SOURCE\n'