1499
1499
# children of non-root directories should not be renamed
1500
1500
self.assertEqual(2, transform_result.rename_count)
1502
def test_build_tree_accelerator_tree(self):
1503
source = self.make_branch_and_tree('source')
1504
self.build_tree_contents([('source/file1', 'A')])
1505
self.build_tree_contents([('source/file2', 'B')])
1506
source.add(['file1', 'file2'], ['file1-id', 'file2-id'])
1507
source.commit('commit files')
1508
self.build_tree_contents([('source/file2', 'C')])
1510
real_source_get_file = source.get_file
1511
def get_file(file_id, path=None):
1512
calls.append(file_id)
1513
return real_source_get_file(file_id, path)
1514
source.get_file = get_file
1516
self.addCleanup(source.unlock)
1517
target = self.make_branch_and_tree('target')
1518
build_tree(source.basis_tree(), target, source)
1519
self.assertEqual(['file1-id'], calls)
1521
def test_build_tree_accelerator_tree_missing_file(self):
1522
source = self.make_branch_and_tree('source')
1523
self.build_tree_contents([('source/file1', 'A')])
1524
self.build_tree_contents([('source/file2', 'B')])
1525
source.add(['file1', 'file2'])
1526
source.commit('commit files')
1527
os.unlink('source/file1')
1528
source.remove(['file2'])
1529
target = self.make_branch_and_tree('target')
1530
build_tree(source.basis_tree(), target, source)
1532
def test_build_tree_accelerator_wrong_kind(self):
1533
source = self.make_branch_and_tree('source')
1534
self.build_tree_contents([('source/file1', '')])
1535
self.build_tree_contents([('source/file2', '')])
1536
source.add(['file1', 'file2'], ['file1-id', 'file2-id'])
1537
source.commit('commit files')
1538
os.unlink('source/file2')
1539
self.build_tree_contents([('source/file2/', 'C')])
1540
os.unlink('source/file1')
1541
os.symlink('file2', 'source/file1')
1543
real_source_get_file = source.get_file
1544
def get_file(file_id, path=None):
1545
calls.append(file_id)
1546
return real_source_get_file(file_id, path)
1547
source.get_file = get_file
1549
self.addCleanup(source.unlock)
1550
target = self.make_branch_and_tree('target')
1551
build_tree(source.basis_tree(), target, source)
1552
self.assertEqual([], calls)
1503
1555
class MockTransform(object):