155
155
transform, root = self.get_transform()
156
156
self.wt.lock_tree_write()
157
157
self.addCleanup(self.wt.unlock)
158
trans_id = transform.new_file('name', root, 'contents',
158
trans_id = transform.new_file('name', root, 'contents',
159
159
'my_pretties', True)
160
160
oz = transform.new_directory('oz', root, 'oz-id')
161
161
dorothy = transform.new_directory('dorothy', oz, 'dorothy-id')
162
toto = transform.new_file('toto', dorothy, 'toto-contents',
162
toto = transform.new_file('toto', dorothy, 'toto-contents',
163
163
'toto-id', False)
165
165
self.assertEqual(len(transform.find_conflicts()), 0)
190
190
def test_conflicts(self):
191
191
transform, root = self.get_transform()
192
trans_id = transform.new_file('name', root, 'contents',
192
trans_id = transform.new_file('name', root, 'contents',
194
194
self.assertEqual(len(transform.find_conflicts()), 0)
195
195
trans_id2 = transform.new_file('name', root, 'Crontents', 'toto')
196
self.assertEqual(transform.find_conflicts(),
196
self.assertEqual(transform.find_conflicts(),
197
197
[('duplicate', trans_id, trans_id2, 'name')])
198
198
self.assertRaises(MalformedTransform, transform.apply)
199
199
transform.adjust_path('name', trans_id, trans_id2)
200
self.assertEqual(transform.find_conflicts(),
200
self.assertEqual(transform.find_conflicts(),
201
201
[('non-directory parent', trans_id)])
202
202
tinman_id = transform.trans_id_tree_path('tinman')
203
203
transform.adjust_path('name', tinman_id, trans_id2)
204
self.assertEqual(transform.find_conflicts(),
205
[('unversioned parent', tinman_id),
204
self.assertEqual(transform.find_conflicts(),
205
[('unversioned parent', tinman_id),
206
206
('missing parent', tinman_id)])
207
207
lion_id = transform.create_path('lion', root)
208
self.assertEqual(transform.find_conflicts(),
209
[('unversioned parent', tinman_id),
208
self.assertEqual(transform.find_conflicts(),
209
[('unversioned parent', tinman_id),
210
210
('missing parent', tinman_id)])
211
211
transform.adjust_path('name', lion_id, trans_id2)
212
self.assertEqual(transform.find_conflicts(),
212
self.assertEqual(transform.find_conflicts(),
213
213
[('unversioned parent', lion_id),
214
214
('missing parent', lion_id)])
215
215
transform.version_file("Courage", lion_id)
216
self.assertEqual(transform.find_conflicts(),
217
[('missing parent', lion_id),
216
self.assertEqual(transform.find_conflicts(),
217
[('missing parent', lion_id),
218
218
('versioning no contents', lion_id)])
219
219
transform.adjust_path('name2', root, trans_id2)
220
self.assertEqual(transform.find_conflicts(),
220
self.assertEqual(transform.find_conflicts(),
221
221
[('versioning no contents', lion_id)])
222
222
transform.create_file('Contents, okay?', lion_id)
223
223
transform.adjust_path('name2', trans_id2, trans_id2)
224
self.assertEqual(transform.find_conflicts(),
225
[('parent loop', trans_id2),
224
self.assertEqual(transform.find_conflicts(),
225
[('parent loop', trans_id2),
226
226
('non-directory parent', trans_id2)])
227
227
transform.adjust_path('name2', root, trans_id2)
228
228
oz_id = transform.new_directory('oz', root)
229
229
transform.set_executability(True, oz_id)
230
self.assertEqual(transform.find_conflicts(),
230
self.assertEqual(transform.find_conflicts(),
231
231
[('unversioned executability', oz_id)])
232
232
transform.version_file('oz-id', oz_id)
233
self.assertEqual(transform.find_conflicts(),
233
self.assertEqual(transform.find_conflicts(),
234
234
[('non-file executability', oz_id)])
235
235
transform.set_executability(None, oz_id)
236
236
tip_id = transform.new_file('tip', oz_id, 'ozma', 'tip-id')
245
245
self.assert_('oz/tip' in transform2._tree_path_ids)
246
246
self.assertEqual(fp.get_path(newtip), pathjoin('oz', 'tip'))
247
247
self.assertEqual(len(result), 2)
248
self.assertEqual((result[0][0], result[0][1]),
248
self.assertEqual((result[0][0], result[0][1]),
249
249
('duplicate', newtip))
250
self.assertEqual((result[1][0], result[1][2]),
250
self.assertEqual((result[1][0], result[1][2]),
251
251
('duplicate id', newtip))
252
252
transform2.finalize()
253
253
transform3 = TreeTransform(self.wt)
254
254
self.addCleanup(transform3.finalize)
255
255
oz_id = transform3.trans_id_tree_file_id('oz-id')
256
256
transform3.delete_contents(oz_id)
257
self.assertEqual(transform3.find_conflicts(),
257
self.assertEqual(transform3.find_conflicts(),
258
258
[('missing parent', oz_id)])
259
259
root_id = transform3.root
260
260
tip_id = transform3.trans_id_tree_file_id('tip-id')
462
462
bzrlib = create_tree.new_directory('bzrlib', root, 'bzrlib-id')
463
463
tests = create_tree.new_directory('tests', bzrlib, 'tests-id')
464
464
blackbox = create_tree.new_directory('blackbox', tests, 'blackbox-id')
465
create_tree.new_file('test_too_much.py', blackbox, 'hello1',
465
create_tree.new_file('test_too_much.py', blackbox, 'hello1',
466
466
'test_too_much-id')
468
468
mangle_tree,root = self.get_transform()
469
469
bzrlib = mangle_tree.trans_id_tree_file_id('bzrlib-id')
470
470
tests = mangle_tree.trans_id_tree_file_id('tests-id')
471
471
test_too_much = mangle_tree.trans_id_tree_file_id('test_too_much-id')
472
472
mangle_tree.adjust_path('selftest', bzrlib, tests)
473
mangle_tree.adjust_path('blackbox.py', tests, test_too_much)
473
mangle_tree.adjust_path('blackbox.py', tests, test_too_much)
474
474
mangle_tree.set_executability(True, test_too_much)
475
475
mangle_tree.apply()
477
477
def test_both_rename3(self):
478
478
create_tree,root = self.get_transform()
479
479
tests = create_tree.new_directory('tests', root, 'tests-id')
480
create_tree.new_file('test_too_much.py', tests, 'hello1',
480
create_tree.new_file('test_too_much.py', tests, 'hello1',
481
481
'test_too_much-id')
483
483
mangle_tree,root = self.get_transform()
484
484
tests = mangle_tree.trans_id_tree_file_id('tests-id')
485
485
test_too_much = mangle_tree.trans_id_tree_file_id('test_too_much-id')
486
486
mangle_tree.adjust_path('selftest', root, tests)
487
mangle_tree.adjust_path('blackbox.py', tests, test_too_much)
487
mangle_tree.adjust_path('blackbox.py', tests, test_too_much)
488
488
mangle_tree.set_executability(True, test_too_much)
489
489
mangle_tree.apply()
529
529
self.requireFeature(SymlinkFeature)
530
530
transform,root = self.get_transform()
531
531
oz_id = transform.new_directory('oz', root, 'oz-id')
532
wizard = transform.new_symlink('wizard', oz_id, 'wizard-target',
532
wizard = transform.new_symlink('wizard', oz_id, 'wizard-target',
534
534
wiz_id = transform.create_path('wizard2', oz_id)
535
535
transform.create_symlink('behind_curtain', wiz_id)
536
transform.version_file('wiz-id2', wiz_id)
536
transform.version_file('wiz-id2', wiz_id)
537
537
transform.set_executability(True, wiz_id)
538
self.assertEqual(transform.find_conflicts(),
538
self.assertEqual(transform.find_conflicts(),
539
539
[('non-file executability', wiz_id)])
540
540
transform.set_executability(None, wiz_id)
541
541
transform.apply()
542
542
self.assertEqual(self.wt.path2id('oz/wizard'), 'wizard-id')
543
543
self.assertEqual(file_kind(self.wt.abspath('oz/wizard')), 'symlink')
544
self.assertEqual(os.readlink(self.wt.abspath('oz/wizard2')),
544
self.assertEqual(os.readlink(self.wt.abspath('oz/wizard2')),
545
545
'behind_curtain')
546
546
self.assertEqual(os.readlink(self.wt.abspath('oz/wizard')),
604
604
tt, emerald, oz, old_dorothy, new_dorothy = self.get_conflicted()
605
605
raw_conflicts = resolve_conflicts(tt)
606
606
cooked_conflicts = cook_conflicts(raw_conflicts, tt)
607
duplicate = DuplicateEntry('Moved existing file to', 'dorothy.moved',
607
duplicate = DuplicateEntry('Moved existing file to', 'dorothy.moved',
608
608
'dorothy', None, 'dorothy-id')
609
609
self.assertEqual(cooked_conflicts[0], duplicate)
610
duplicate_id = DuplicateID('Unversioned existing file',
610
duplicate_id = DuplicateID('Unversioned existing file',
611
611
'dorothy.moved', 'dorothy', None,
613
613
self.assertEqual(cooked_conflicts[1], duplicate_id)
1420
1420
self.assertEqual(this.wt.get_file('e').read(), 'e2')
1422
1422
self.assertEqual(this.wt.get_file('f').read(), 'f')
1423
# Correct correct results when THIS == OTHER
1423
# Correct correct results when THIS == OTHER
1424
1424
self.assertEqual(this.wt.get_file('g').read(), 'g')
1425
1425
# Text conflict when THIS & OTHER are text and BASE is dir
1426
self.assertEqual(this.wt.get_file('h').read(),
1426
self.assertEqual(this.wt.get_file('h').read(),
1427
1427
conflict_text('1\n2\n3\n4\n', 'h\ni\nj\nk\n'))
1428
1428
self.assertEqual(this.wt.get_file_byname('h.THIS').read(),
1429
1429
'1\n2\n3\n4\n')
1430
1430
self.assertEqual(this.wt.get_file_byname('h.OTHER').read(),
1431
1431
'h\ni\nj\nk\n')
1432
1432
self.assertEqual(file_kind(this.wt.abspath('h.BASE')), 'directory')
1433
self.assertEqual(this.wt.get_file('i').read(),
1433
self.assertEqual(this.wt.get_file('i').read(),
1434
1434
conflict_text('1\n2\n3\n4\n', 'h\ni\nj\nk\n'))
1435
1435
self.assertEqual(this.wt.get_file_byname('i.THIS').read(),
1436
1436
'1\n2\n3\n4\n')
1460
1460
tg.tt.new_symlink('b', tg.root, 'b', 'b')
1461
1461
tg.tt.new_file('c', tg.root, 'c', 'c')
1462
1462
tg.tt.new_symlink('d', tg.root, tg.name, 'd')
1463
targets = ((base, 'base-e', 'base-f', None, None),
1464
(this, 'other-e', 'this-f', 'other-g', 'this-h'),
1463
targets = ((base, 'base-e', 'base-f', None, None),
1464
(this, 'other-e', 'this-f', 'other-g', 'this-h'),
1465
1465
(other, 'other-e', None, 'other-g', 'other-h'))
1466
1466
for tg, e_target, f_target, g_target, h_target in targets:
1467
for link, target in (('e', e_target), ('f', f_target),
1467
for link, target in (('e', e_target), ('f', f_target),
1468
1468
('g', g_target), ('h', h_target)):
1469
1469
if target is not None:
1470
1470
tg.tt.new_symlink(link, tg.root, target, link)
1496
1496
base = TransformGroup("BASE", root_id)
1497
1497
this = TransformGroup("THIS", root_id)
1498
1498
other = TransformGroup("OTHER", root_id)
1499
base_a, this_a, other_a = [t.tt.new_directory('a', t.root, 'a')
1499
base_a, this_a, other_a = [t.tt.new_directory('a', t.root, 'a')
1500
1500
for t in [base, this, other]]
1501
base_b, this_b, other_b = [t.tt.new_directory('b', t.root, 'b')
1501
base_b, this_b, other_b = [t.tt.new_directory('b', t.root, 'b')
1502
1502
for t in [base, this, other]]
1503
1503
base.tt.new_directory('c', base_a, 'c')
1504
1504
this.tt.new_directory('c1', this_a, 'c')
1529
1529
base = TransformGroup("BASE", root_id)
1530
1530
this = TransformGroup("THIS", root_id)
1531
1531
other = TransformGroup("OTHER", root_id)
1532
base_a, this_a, other_a = [t.tt.new_directory('a', t.root, 'a')
1532
base_a, this_a, other_a = [t.tt.new_directory('a', t.root, 'a')
1533
1533
for t in [base, this, other]]
1534
base_b, this_b, other_b = [t.tt.new_directory('b', t.root, 'b')
1534
base_b, this_b, other_b = [t.tt.new_directory('b', t.root, 'b')
1535
1535
for t in [base, this, other]]
1537
1537
base.tt.new_file('g', base_a, 'g', 'g')