~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_transform.py

  • Committer: Andrew Bennetts
  • Date: 2008-03-27 06:10:18 UTC
  • mfrom: (3309 +trunk)
  • mto: This revision was merged to the branch mainline in revision 3320.
  • Revision ID: andrew.bennetts@canonical.com-20080327061018-dxztpxyv6yoeg3am
Merge from bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
import os
18
18
import stat
 
19
from StringIO import StringIO
19
20
import sys
20
21
 
21
22
from bzrlib import (
22
23
    errors,
23
24
    generate_ids,
 
25
    osutils,
 
26
    progress,
 
27
    revision as _mod_revision,
24
28
    symbol_versioning,
25
29
    tests,
26
30
    urlutils,
29
33
from bzrlib.conflicts import (DuplicateEntry, DuplicateID, MissingParent,
30
34
                              UnversionedParent, ParentLoop, DeletingParent,
31
35
                              NonDirectoryParent)
 
36
from bzrlib.diff import show_diff_trees
32
37
from bzrlib.errors import (DuplicateKey, MalformedTransform, NoSuchFile,
33
38
                           ReusingTransform, CantMoveRoot, 
34
39
                           PathsNotVersionedError, ExistingLimbo,
38
43
from bzrlib.merge import Merge3Merger
39
44
from bzrlib.tests import (
40
45
    CaseInsensitiveFilesystemFeature,
 
46
    HardlinkFeature,
41
47
    SymlinkFeature,
42
48
    TestCase,
43
49
    TestCaseInTempDir,
46
52
from bzrlib.transform import (TreeTransform, ROOT_PARENT, FinalPaths, 
47
53
                              resolve_conflicts, cook_conflicts, 
48
54
                              find_interesting, build_tree, get_backup_name,
49
 
                              change_entry, _FileMover, resolve_checkout)
50
 
 
 
55
                              change_entry, _FileMover, resolve_checkout,
 
56
                              TransformPreview)
51
57
 
52
58
class TestTreeTransform(tests.TestCaseWithTransport):
53
59
 
129
135
        transform.finalize()
130
136
        transform.finalize()
131
137
 
 
138
    def test_hardlink(self):
 
139
        self.requireFeature(HardlinkFeature)
 
140
        transform, root = self.get_transform()
 
141
        transform.new_file('file1', root, 'contents')
 
142
        transform.apply()
 
143
        target = self.make_branch_and_tree('target')
 
144
        target_transform = TreeTransform(target)
 
145
        trans_id = target_transform.create_path('file1', target_transform.root)
 
146
        target_transform.create_hardlink(self.wt.abspath('file1'), trans_id)
 
147
        target_transform.apply()
 
148
        self.failUnlessExists('target/file1')
 
149
        source_stat = os.stat(self.wt.abspath('file1'))
 
150
        target_stat = os.stat('target/file1')
 
151
        self.assertEqual(source_stat, target_stat)
 
152
 
132
153
    def test_convenience(self):
133
154
        transform, root = self.get_transform()
134
155
        self.wt.lock_tree_write()
251
272
        transform.new_file('FiLe', transform.root, 'content')
252
273
        result = transform.find_conflicts()
253
274
        self.assertEqual([], result)
 
275
        transform.finalize()
254
276
        # Force the tree to report that it is case insensitive, for conflict
255
277
        # generation tests
256
278
        tree.case_sensitive = False
 
279
        transform = TreeTransform(tree)
 
280
        self.addCleanup(transform.finalize)
 
281
        transform.new_file('file', transform.root, 'content')
 
282
        transform.new_file('FiLe', transform.root, 'content')
257
283
        result = transform.find_conflicts()
258
284
        self.assertEqual([('duplicate', 'new-1', 'new-2', 'file')], result)
259
285
 
269
295
        transform.new_file('file', transform.root, 'content')
270
296
        result = transform.find_conflicts()
271
297
        self.assertEqual([], result)
 
298
        transform.finalize()
272
299
        # Force the tree to report that it is case insensitive, for conflict
273
300
        # generation tests
274
301
        tree.case_sensitive = False
 
302
        transform = TreeTransform(tree)
 
303
        self.addCleanup(transform.finalize)
 
304
        transform.new_file('file', transform.root, 'content')
275
305
        result = transform.find_conflicts()
276
306
        self.assertEqual([('duplicate', 'new-1', 'new-2', 'file')], result)
277
307
 
806
836
        transform.apply()
807
837
        transform, root = self.get_transform()
808
838
        try:
809
 
            self.assertEqual([], list(transform._iter_changes()))
 
839
            self.assertEqual([], list(transform.iter_changes()))
810
840
            old = transform.trans_id_tree_file_id('id-1')
811
841
            transform.unversion_file(old)
812
842
            self.assertEqual([('id-1', ('old', None), False, (True, False),
813
843
                ('eert_toor', 'eert_toor'), ('old', 'old'), ('file', 'file'),
814
 
                (True, True))], list(transform._iter_changes()))
 
844
                (True, True))], list(transform.iter_changes()))
815
845
            transform.new_directory('new', root, 'id-1')
816
846
            self.assertEqual([('id-1', ('old', 'new'), True, (True, True),
817
847
                ('eert_toor', 'eert_toor'), ('old', 'new'),
818
848
                ('file', 'directory'),
819
 
                (True, False))], list(transform._iter_changes()))
 
849
                (True, False))], list(transform.iter_changes()))
820
850
        finally:
821
851
            transform.finalize()
822
852
 
831
861
            transform.version_file('id-1', old)
832
862
            self.assertEqual([('id-1', (None, 'old'), False, (False, True),
833
863
                ('eert_toor', 'eert_toor'), ('old', 'old'), ('file', 'file'),
834
 
                (False, False))], list(transform._iter_changes()))
 
864
                (False, False))], list(transform.iter_changes()))
835
865
        finally:
836
866
            transform.finalize()
837
867
 
847
877
            old = transform.trans_id_tree_path('old')
848
878
            subdir = transform.trans_id_tree_file_id('subdir-id')
849
879
            new = transform.trans_id_tree_path('new')
850
 
            self.assertEqual([], list(transform._iter_changes()))
 
880
            self.assertEqual([], list(transform.iter_changes()))
851
881
 
852
882
            #content deletion
853
883
            transform.delete_contents(old)
854
884
            self.assertEqual([('id-1', ('old', 'old'), True, (True, True),
855
885
                ('eert_toor', 'eert_toor'), ('old', 'old'), ('file', None),
856
 
                (False, False))], list(transform._iter_changes()))
 
886
                (False, False))], list(transform.iter_changes()))
857
887
 
858
888
            #content change
859
889
            transform.create_file('blah', old)
860
890
            self.assertEqual([('id-1', ('old', 'old'), True, (True, True),
861
891
                ('eert_toor', 'eert_toor'), ('old', 'old'), ('file', 'file'),
862
 
                (False, False))], list(transform._iter_changes()))
 
892
                (False, False))], list(transform.iter_changes()))
863
893
            transform.cancel_deletion(old)
864
894
            self.assertEqual([('id-1', ('old', 'old'), True, (True, True),
865
895
                ('eert_toor', 'eert_toor'), ('old', 'old'), ('file', 'file'),
866
 
                (False, False))], list(transform._iter_changes()))
 
896
                (False, False))], list(transform.iter_changes()))
867
897
            transform.cancel_creation(old)
868
898
 
869
899
            # move file_id to a different file
870
 
            self.assertEqual([], list(transform._iter_changes()))
 
900
            self.assertEqual([], list(transform.iter_changes()))
871
901
            transform.unversion_file(old)
872
902
            transform.version_file('id-1', new)
873
903
            transform.adjust_path('old', root, new)
874
904
            self.assertEqual([('id-1', ('old', 'old'), True, (True, True),
875
905
                ('eert_toor', 'eert_toor'), ('old', 'old'), ('file', 'file'),
876
 
                (False, False))], list(transform._iter_changes()))
 
906
                (False, False))], list(transform.iter_changes()))
877
907
            transform.cancel_versioning(new)
878
908
            transform._removed_id = set()
879
909
 
880
910
            #execute bit
881
 
            self.assertEqual([], list(transform._iter_changes()))
 
911
            self.assertEqual([], list(transform.iter_changes()))
882
912
            transform.set_executability(True, old)
883
913
            self.assertEqual([('id-1', ('old', 'old'), False, (True, True),
884
914
                ('eert_toor', 'eert_toor'), ('old', 'old'), ('file', 'file'),
885
 
                (False, True))], list(transform._iter_changes()))
 
915
                (False, True))], list(transform.iter_changes()))
886
916
            transform.set_executability(None, old)
887
917
 
888
918
            # filename
889
 
            self.assertEqual([], list(transform._iter_changes()))
 
919
            self.assertEqual([], list(transform.iter_changes()))
890
920
            transform.adjust_path('new', root, old)
891
921
            transform._new_parent = {}
892
922
            self.assertEqual([('id-1', ('old', 'new'), False, (True, True),
893
923
                ('eert_toor', 'eert_toor'), ('old', 'new'), ('file', 'file'),
894
 
                (False, False))], list(transform._iter_changes()))
 
924
                (False, False))], list(transform.iter_changes()))
895
925
            transform._new_name = {}
896
926
 
897
927
            # parent directory
898
 
            self.assertEqual([], list(transform._iter_changes()))
 
928
            self.assertEqual([], list(transform.iter_changes()))
899
929
            transform.adjust_path('new', subdir, old)
900
930
            transform._new_name = {}
901
931
            self.assertEqual([('id-1', ('old', 'subdir/old'), False,
902
932
                (True, True), ('eert_toor', 'subdir-id'), ('old', 'old'),
903
933
                ('file', 'file'), (False, False))],
904
 
                list(transform._iter_changes()))
 
934
                list(transform.iter_changes()))
905
935
            transform._new_path = {}
906
936
 
907
937
        finally:
929
959
                ('id-2', (u'file2', u'file2'), False, (True, True),
930
960
                ('eert_toor', 'eert_toor'), ('file2', u'file2'),
931
961
                ('file', 'file'), (False, True))],
932
 
                list(transform._iter_changes()))
 
962
                list(transform.iter_changes()))
933
963
        finally:
934
964
            transform.finalize()
935
965
 
949
979
            transform.adjust_path('flitter', root, floater)
950
980
            self.assertEqual([('floater-id', ('floater', 'flitter'), False,
951
981
            (True, True), ('toor_eert', 'toor_eert'), ('floater', 'flitter'),
952
 
            (None, None), (False, False))], list(transform._iter_changes()))
 
982
            (None, None), (False, False))], list(transform.iter_changes()))
953
983
        finally:
954
984
            transform.finalize()
955
985
 
964
994
        try:
965
995
            old = transform.trans_id_tree_path('old')
966
996
            subdir = transform.trans_id_tree_file_id('subdir-id')
967
 
            self.assertEqual([], list(transform._iter_changes()))
 
997
            self.assertEqual([], list(transform.iter_changes()))
968
998
            transform.delete_contents(subdir)
969
999
            transform.create_directory(subdir)
970
1000
            transform.set_executability(False, old)
971
1001
            transform.unversion_file(old)
972
1002
            transform.version_file('id-1', old)
973
1003
            transform.adjust_path('old', root, old)
974
 
            self.assertEqual([], list(transform._iter_changes()))
 
1004
            self.assertEqual([], list(transform.iter_changes()))
975
1005
        finally:
976
1006
            transform.finalize()
977
1007
 
1219
1249
 
1220
1250
 
1221
1251
class TestTransformMerge(TestCaseInTempDir):
 
1252
 
1222
1253
    def test_text_merge(self):
1223
1254
        root_id = generate_ids.gen_root_id()
1224
1255
        base = TransformGroup("base", root_id)
1254
1285
        this.tt.new_file('i', this.root, '1\n2\n3\n4\n', 'i')
1255
1286
        this.tt.apply()
1256
1287
        Merge3Merger(this.wt, this.wt, base.wt, other.wt)
 
1288
 
1257
1289
        # textual merge
1258
1290
        self.assertEqual(this.wt.get_file('a').read(), 'y\nb\nc\nd\bz\n')
1259
1291
        # three-way text conflict
1557
1589
        # children of non-root directories should not be renamed
1558
1590
        self.assertEqual(2, transform_result.rename_count)
1559
1591
 
 
1592
    def create_ab_tree(self):
 
1593
        """Create a committed test tree with two files"""
 
1594
        source = self.make_branch_and_tree('source')
 
1595
        self.build_tree_contents([('source/file1', 'A')])
 
1596
        self.build_tree_contents([('source/file2', 'B')])
 
1597
        source.add(['file1', 'file2'], ['file1-id', 'file2-id'])
 
1598
        source.commit('commit files')
 
1599
        source.lock_write()
 
1600
        self.addCleanup(source.unlock)
 
1601
        return source
 
1602
 
1560
1603
    def test_build_tree_accelerator_tree(self):
1561
 
        source = self.make_branch_and_tree('source')
1562
 
        self.build_tree_contents([('source/file1', 'A')])
1563
 
        self.build_tree_contents([('source/file2', 'B')])
1564
 
        source.add(['file1', 'file2'], ['file1-id', 'file2-id'])
1565
 
        source.commit('commit files')
 
1604
        source = self.create_ab_tree()
1566
1605
        self.build_tree_contents([('source/file2', 'C')])
1567
1606
        calls = []
1568
1607
        real_source_get_file = source.get_file
1570
1609
            calls.append(file_id)
1571
1610
            return real_source_get_file(file_id, path)
1572
1611
        source.get_file = get_file
1573
 
        source.lock_read()
1574
 
        self.addCleanup(source.unlock)
1575
1612
        target = self.make_branch_and_tree('target')
1576
1613
        revision_tree = source.basis_tree()
1577
1614
        revision_tree.lock_read()
1580
1617
        self.assertEqual(['file1-id'], calls)
1581
1618
        target.lock_read()
1582
1619
        self.addCleanup(target.unlock)
1583
 
        self.assertEqual([], list(target._iter_changes(revision_tree)))
 
1620
        self.assertEqual([], list(target.iter_changes(revision_tree)))
1584
1621
 
1585
1622
    def test_build_tree_accelerator_tree_missing_file(self):
1586
 
        source = self.make_branch_and_tree('source')
1587
 
        self.build_tree_contents([('source/file1', 'A')])
1588
 
        self.build_tree_contents([('source/file2', 'B')])
1589
 
        source.add(['file1', 'file2'])
1590
 
        source.commit('commit files')
 
1623
        source = self.create_ab_tree()
1591
1624
        os.unlink('source/file1')
1592
1625
        source.remove(['file2'])
1593
1626
        target = self.make_branch_and_tree('target')
1597
1630
        build_tree(revision_tree, target, source)
1598
1631
        target.lock_read()
1599
1632
        self.addCleanup(target.unlock)
1600
 
        self.assertEqual([], list(target._iter_changes(revision_tree)))
 
1633
        self.assertEqual([], list(target.iter_changes(revision_tree)))
1601
1634
 
1602
1635
    def test_build_tree_accelerator_wrong_kind(self):
1603
1636
        self.requireFeature(SymlinkFeature)
1616
1649
            calls.append(file_id)
1617
1650
            return real_source_get_file(file_id, path)
1618
1651
        source.get_file = get_file
1619
 
        source.lock_read()
1620
 
        self.addCleanup(source.unlock)
1621
1652
        target = self.make_branch_and_tree('target')
1622
1653
        revision_tree = source.basis_tree()
1623
1654
        revision_tree.lock_read()
1626
1657
        self.assertEqual([], calls)
1627
1658
        target.lock_read()
1628
1659
        self.addCleanup(target.unlock)
1629
 
        self.assertEqual([], list(target._iter_changes(revision_tree)))
 
1660
        self.assertEqual([], list(target.iter_changes(revision_tree)))
 
1661
 
 
1662
    def test_build_tree_hardlink(self):
 
1663
        self.requireFeature(HardlinkFeature)
 
1664
        source = self.create_ab_tree()
 
1665
        target = self.make_branch_and_tree('target')
 
1666
        revision_tree = source.basis_tree()
 
1667
        revision_tree.lock_read()
 
1668
        self.addCleanup(revision_tree.unlock)
 
1669
        build_tree(revision_tree, target, source, hardlink=True)
 
1670
        target.lock_read()
 
1671
        self.addCleanup(target.unlock)
 
1672
        self.assertEqual([], list(target.iter_changes(revision_tree)))
 
1673
        source_stat = os.stat('source/file1')
 
1674
        target_stat = os.stat('target/file1')
 
1675
        self.assertEqual(source_stat, target_stat)
 
1676
 
 
1677
        # Explicitly disallowing hardlinks should prevent them.
 
1678
        target2 = self.make_branch_and_tree('target2')
 
1679
        build_tree(revision_tree, target2, source, hardlink=False)
 
1680
        target2.lock_read()
 
1681
        self.addCleanup(target2.unlock)
 
1682
        self.assertEqual([], list(target2.iter_changes(revision_tree)))
 
1683
        source_stat = os.stat('source/file1')
 
1684
        target2_stat = os.stat('target2/file1')
 
1685
        self.assertNotEqual(source_stat, target2_stat)
1630
1686
 
1631
1687
    def test_build_tree_accelerator_tree_moved(self):
1632
1688
        source = self.make_branch_and_tree('source')
1643
1699
        build_tree(revision_tree, target, source)
1644
1700
        target.lock_read()
1645
1701
        self.addCleanup(target.unlock)
1646
 
        self.assertEqual([], list(target._iter_changes(revision_tree)))
 
1702
        self.assertEqual([], list(target.iter_changes(revision_tree)))
 
1703
 
 
1704
    def test_build_tree_hardlinks_preserve_execute(self):
 
1705
        self.requireFeature(HardlinkFeature)
 
1706
        source = self.create_ab_tree()
 
1707
        tt = TreeTransform(source)
 
1708
        trans_id = tt.trans_id_tree_file_id('file1-id')
 
1709
        tt.set_executability(True, trans_id)
 
1710
        tt.apply()
 
1711
        self.assertTrue(source.is_executable('file1-id'))
 
1712
        target = self.make_branch_and_tree('target')
 
1713
        revision_tree = source.basis_tree()
 
1714
        revision_tree.lock_read()
 
1715
        self.addCleanup(revision_tree.unlock)
 
1716
        build_tree(revision_tree, target, source, hardlink=True)
 
1717
        target.lock_read()
 
1718
        self.addCleanup(target.unlock)
 
1719
        self.assertEqual([], list(target.iter_changes(revision_tree)))
 
1720
        self.assertTrue(source.is_executable('file1-id'))
1647
1721
 
1648
1722
 
1649
1723
class MockTransform(object):
1804
1878
        parent = tt.trans_id_file_id('parent-id')
1805
1879
        tt.new_file('file', parent, 'Contents')
1806
1880
        resolve_conflicts(tt)
 
1881
 
 
1882
 
 
1883
class TestTransformPreview(tests.TestCaseWithTransport):
 
1884
 
 
1885
    def create_tree(self):
 
1886
        tree = self.make_branch_and_tree('.')
 
1887
        self.build_tree_contents([('a', 'content 1')])
 
1888
        tree.add('a', 'a-id')
 
1889
        tree.commit('rev1', rev_id='rev1')
 
1890
        return tree.branch.repository.revision_tree('rev1')
 
1891
 
 
1892
    def get_empty_preview(self):
 
1893
        repository = self.make_repository('repo')
 
1894
        tree = repository.revision_tree(_mod_revision.NULL_REVISION)
 
1895
        preview = TransformPreview(tree)
 
1896
        self.addCleanup(preview.finalize)
 
1897
        return preview
 
1898
 
 
1899
    def test_transform_preview(self):
 
1900
        revision_tree = self.create_tree()
 
1901
        preview = TransformPreview(revision_tree)
 
1902
        self.addCleanup(preview.finalize)
 
1903
 
 
1904
    def test_transform_preview_tree(self):
 
1905
        revision_tree = self.create_tree()
 
1906
        preview = TransformPreview(revision_tree)
 
1907
        self.addCleanup(preview.finalize)
 
1908
        preview.get_preview_tree()
 
1909
 
 
1910
    def test_transform_new_file(self):
 
1911
        revision_tree = self.create_tree()
 
1912
        preview = TransformPreview(revision_tree)
 
1913
        self.addCleanup(preview.finalize)
 
1914
        preview.new_file('file2', preview.root, 'content B\n', 'file2-id')
 
1915
        preview_tree = preview.get_preview_tree()
 
1916
        self.assertEqual(preview_tree.kind('file2-id'), 'file')
 
1917
        self.assertEqual(
 
1918
            preview_tree.get_file('file2-id').read(), 'content B\n')
 
1919
 
 
1920
    def test_diff_preview_tree(self):
 
1921
        revision_tree = self.create_tree()
 
1922
        preview = TransformPreview(revision_tree)
 
1923
        self.addCleanup(preview.finalize)
 
1924
        preview.new_file('file2', preview.root, 'content B\n', 'file2-id')
 
1925
        preview_tree = preview.get_preview_tree()
 
1926
        out = StringIO()
 
1927
        show_diff_trees(revision_tree, preview_tree, out)
 
1928
        lines = out.getvalue().splitlines()
 
1929
        self.assertEqual(lines[0], "=== added file 'file2'")
 
1930
        # 3 lines of diff administrivia
 
1931
        self.assertEqual(lines[4], "+content B")
 
1932
 
 
1933
    def test_transform_conflicts(self):
 
1934
        revision_tree = self.create_tree()
 
1935
        preview = TransformPreview(revision_tree)
 
1936
        self.addCleanup(preview.finalize)
 
1937
        preview.new_file('a', preview.root, 'content 2')
 
1938
        resolve_conflicts(preview)
 
1939
        trans_id = preview.trans_id_file_id('a-id')
 
1940
        self.assertEqual('a.moved', preview.final_name(trans_id))
 
1941
 
 
1942
    def get_tree_and_preview_tree(self):
 
1943
        revision_tree = self.create_tree()
 
1944
        preview = TransformPreview(revision_tree)
 
1945
        self.addCleanup(preview.finalize)
 
1946
        a_trans_id = preview.trans_id_file_id('a-id')
 
1947
        preview.delete_contents(a_trans_id)
 
1948
        preview.create_file('b content', a_trans_id)
 
1949
        preview_tree = preview.get_preview_tree()
 
1950
        return revision_tree, preview_tree
 
1951
 
 
1952
    def test_iter_changes(self):
 
1953
        revision_tree, preview_tree = self.get_tree_and_preview_tree()
 
1954
        root = revision_tree.inventory.root.file_id
 
1955
        self.assertEqual([('a-id', ('a', 'a'), True, (True, True),
 
1956
                          (root, root), ('a', 'a'), ('file', 'file'),
 
1957
                          (False, False))],
 
1958
                          list(preview_tree.iter_changes(revision_tree)))
 
1959
 
 
1960
    def test_wrong_tree_value_error(self):
 
1961
        revision_tree, preview_tree = self.get_tree_and_preview_tree()
 
1962
        e = self.assertRaises(ValueError, preview_tree.iter_changes,
 
1963
                              preview_tree)
 
1964
        self.assertEqual('from_tree must be transform source tree.', str(e))
 
1965
 
 
1966
    def test_include_unchanged_value_error(self):
 
1967
        revision_tree, preview_tree = self.get_tree_and_preview_tree()
 
1968
        e = self.assertRaises(ValueError, preview_tree.iter_changes,
 
1969
                              revision_tree, include_unchanged=True)
 
1970
        self.assertEqual('include_unchanged is not supported', str(e))
 
1971
 
 
1972
    def test_specific_files(self):
 
1973
        revision_tree, preview_tree = self.get_tree_and_preview_tree()
 
1974
        e = self.assertRaises(ValueError, preview_tree.iter_changes,
 
1975
                              revision_tree, specific_files=['pete'])
 
1976
        self.assertEqual('specific_files is not supported', str(e))
 
1977
 
 
1978
    def test_want_unversioned_value_error(self):
 
1979
        revision_tree, preview_tree = self.get_tree_and_preview_tree()
 
1980
        e = self.assertRaises(ValueError, preview_tree.iter_changes,
 
1981
                              revision_tree, want_unversioned=True)
 
1982
        self.assertEqual('want_unversioned is not supported', str(e))
 
1983
 
 
1984
    def test_ignore_extra_trees_no_specific_files(self):
 
1985
        # extra_trees is harmless without specific_files, so we'll silently
 
1986
        # accept it, even though we won't use it.
 
1987
        revision_tree, preview_tree = self.get_tree_and_preview_tree()
 
1988
        preview_tree.iter_changes(revision_tree, extra_trees=[preview_tree])
 
1989
 
 
1990
    def test_ignore_require_versioned_no_specific_files(self):
 
1991
        # require_versioned is meaningless without specific_files.
 
1992
        revision_tree, preview_tree = self.get_tree_and_preview_tree()
 
1993
        preview_tree.iter_changes(revision_tree, require_versioned=False)
 
1994
 
 
1995
    def test_ignore_pb(self):
 
1996
        # pb could be supported, but TT.iter_changes doesn't support it.
 
1997
        revision_tree, preview_tree = self.get_tree_and_preview_tree()
 
1998
        preview_tree.iter_changes(revision_tree, pb=progress.DummyProgress())
 
1999
 
 
2000
    def test_kind(self):
 
2001
        revision_tree = self.create_tree()
 
2002
        preview = TransformPreview(revision_tree)
 
2003
        self.addCleanup(preview.finalize)
 
2004
        preview.new_file('file', preview.root, 'contents', 'file-id')
 
2005
        preview.new_directory('directory', preview.root, 'dir-id')
 
2006
        preview_tree = preview.get_preview_tree()
 
2007
        self.assertEqual('file', preview_tree.kind('file-id'))
 
2008
        self.assertEqual('directory', preview_tree.kind('dir-id'))
 
2009
 
 
2010
    def test_get_file_mtime(self):
 
2011
        preview = self.get_empty_preview()
 
2012
        file_trans_id = preview.new_file('file', preview.root, 'contents',
 
2013
                                         'file-id')
 
2014
        limbo_path = preview._limbo_name(file_trans_id)
 
2015
        preview_tree = preview.get_preview_tree()
 
2016
        self.assertEqual(os.stat(limbo_path).st_mtime,
 
2017
                         preview_tree.get_file_mtime('file-id'))
 
2018
 
 
2019
    def test_get_file(self):
 
2020
        preview = self.get_empty_preview()
 
2021
        preview.new_file('file', preview.root, 'contents', 'file-id')
 
2022
        preview_tree = preview.get_preview_tree()
 
2023
        tree_file = preview_tree.get_file('file-id')
 
2024
        try:
 
2025
            self.assertEqual('contents', tree_file.read())
 
2026
        finally:
 
2027
            tree_file.close()
 
2028
 
 
2029
    def test_get_symlink_target(self):
 
2030
        self.requireFeature(SymlinkFeature)
 
2031
        preview = self.get_empty_preview()
 
2032
        preview.new_symlink('symlink', preview.root, 'target', 'symlink-id')
 
2033
        preview_tree = preview.get_preview_tree()
 
2034
        self.assertEqual('target',
 
2035
                         preview_tree.get_symlink_target('symlink-id'))