~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transform.py

  • Committer: Aaron Bentley
  • Date: 2007-12-29 03:31:14 UTC
  • mfrom: (3146 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3187.
  • Revision ID: aaron.bentley@utoronto.ca-20071229033114-kt1waj0m4iwig1o3
Merge bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
1499
1499
        # children of non-root directories should not be renamed
1500
1500
        self.assertEqual(2, transform_result.rename_count)
1501
1501
 
 
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')])
 
1509
        calls = []
 
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
 
1515
        source.lock_read()
 
1516
        self.addCleanup(source.unlock)
 
1517
        target = self.make_branch_and_tree('target')
 
1518
        revision_tree = source.basis_tree()
 
1519
        revision_tree.lock_read()
 
1520
        self.addCleanup(revision_tree.unlock)
 
1521
        build_tree(revision_tree, target, source)
 
1522
        self.assertEqual(['file1-id'], calls)
 
1523
        target.lock_read()
 
1524
        self.addCleanup(target.unlock)
 
1525
        self.assertEqual([], list(target._iter_changes(revision_tree)))
 
1526
 
 
1527
    def test_build_tree_accelerator_tree_missing_file(self):
 
1528
        source = self.make_branch_and_tree('source')
 
1529
        self.build_tree_contents([('source/file1', 'A')])
 
1530
        self.build_tree_contents([('source/file2', 'B')])
 
1531
        source.add(['file1', 'file2'])
 
1532
        source.commit('commit files')
 
1533
        os.unlink('source/file1')
 
1534
        source.remove(['file2'])
 
1535
        target = self.make_branch_and_tree('target')
 
1536
        revision_tree = source.basis_tree()
 
1537
        revision_tree.lock_read()
 
1538
        self.addCleanup(revision_tree.unlock)
 
1539
        build_tree(revision_tree, target, source)
 
1540
        target.lock_read()
 
1541
        self.addCleanup(target.unlock)
 
1542
        self.assertEqual([], list(target._iter_changes(revision_tree)))
 
1543
 
 
1544
    def test_build_tree_accelerator_wrong_kind(self):
 
1545
        source = self.make_branch_and_tree('source')
 
1546
        self.build_tree_contents([('source/file1', '')])
 
1547
        self.build_tree_contents([('source/file2', '')])
 
1548
        source.add(['file1', 'file2'], ['file1-id', 'file2-id'])
 
1549
        source.commit('commit files')
 
1550
        os.unlink('source/file2')
 
1551
        self.build_tree_contents([('source/file2/', 'C')])
 
1552
        os.unlink('source/file1')
 
1553
        os.symlink('file2', 'source/file1')
 
1554
        calls = []
 
1555
        real_source_get_file = source.get_file
 
1556
        def get_file(file_id, path=None):
 
1557
            calls.append(file_id)
 
1558
            return real_source_get_file(file_id, path)
 
1559
        source.get_file = get_file
 
1560
        source.lock_read()
 
1561
        self.addCleanup(source.unlock)
 
1562
        target = self.make_branch_and_tree('target')
 
1563
        revision_tree = source.basis_tree()
 
1564
        revision_tree.lock_read()
 
1565
        self.addCleanup(revision_tree.unlock)
 
1566
        build_tree(revision_tree, target, source)
 
1567
        self.assertEqual([], calls)
 
1568
        target.lock_read()
 
1569
        self.addCleanup(target.unlock)
 
1570
        self.assertEqual([], list(target._iter_changes(revision_tree)))
 
1571
 
 
1572
    def test_build_tree_accelerator_tree_moved(self):
 
1573
        source = self.make_branch_and_tree('source')
 
1574
        self.build_tree_contents([('source/file1', 'A')])
 
1575
        source.add(['file1'], ['file1-id'])
 
1576
        source.commit('commit files')
 
1577
        source.rename_one('file1', 'file2')
 
1578
        source.lock_read()
 
1579
        self.addCleanup(source.unlock)
 
1580
        target = self.make_branch_and_tree('target')
 
1581
        revision_tree = source.basis_tree()
 
1582
        revision_tree.lock_read()
 
1583
        self.addCleanup(revision_tree.unlock)
 
1584
        build_tree(revision_tree, target, source)
 
1585
        target.lock_read()
 
1586
        self.addCleanup(target.unlock)
 
1587
        self.assertEqual([], list(target._iter_changes(revision_tree)))
 
1588
 
1502
1589
 
1503
1590
class MockTransform(object):
1504
1591