/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transform.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2007-12-20 16:16:34 UTC
  • mfrom: (3123.5.18 hardlinks)
  • Revision ID: pqm@pqm.ubuntu.com-20071220161634-2kcjb650o21ydko4
Accelerate build_tree using similar workingtrees (abentley)

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
        build_tree(source.basis_tree(), target, source)
 
1519
        self.assertEqual(['file1-id'], calls)
 
1520
 
 
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)
 
1531
 
 
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')
 
1542
        calls = []
 
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
 
1548
        source.lock_read()
 
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)
 
1553
 
1502
1554
 
1503
1555
class MockTransform(object):
1504
1556