1832
1833
def get_empty_preview(self):
1833
1834
repository = self.make_repository('repo')
1834
1835
tree = repository.revision_tree(_mod_revision.NULL_REVISION)
1835
return TransformPreview(tree)
1836
preview = TransformPreview(tree)
1837
self.addPreviewCleanup(preview)
1840
def addPreviewCleanup(self, preview):
1841
# This probably indicates a problem in the TransformPreview
1842
# API. finalize() can't be called in tests unsing addPreviewCleanup
1843
# because no lock is held.
1844
self.addCleanup(lambda: osutils.rmtree(preview._limbodir))
1837
1846
def test_transform_preview(self):
1838
1847
revision_tree = self.create_tree()
1839
1848
preview = TransformPreview(revision_tree)
1849
self.addPreviewCleanup(preview)
1841
1851
def test_transform_preview_tree(self):
1842
1852
revision_tree = self.create_tree()
1843
1853
preview = TransformPreview(revision_tree)
1854
self.addPreviewCleanup(preview)
1844
1855
preview.get_preview_tree()
1846
1857
def test_transform_new_file(self):
1847
1858
revision_tree = self.create_tree()
1848
1859
preview = TransformPreview(revision_tree)
1860
self.addPreviewCleanup(preview)
1849
1861
preview.new_file('file2', preview.root, 'content B\n', 'file2-id')
1850
1862
preview_tree = preview.get_preview_tree()
1851
1863
self.assertEqual(preview_tree.kind('file2-id'), 'file')
1855
1867
def test_diff_preview_tree(self):
1856
1868
revision_tree = self.create_tree()
1857
1869
preview = TransformPreview(revision_tree)
1870
self.addPreviewCleanup(preview)
1858
1871
preview.new_file('file2', preview.root, 'content B\n', 'file2-id')
1859
1872
preview_tree = preview.get_preview_tree()
1860
1873
out = StringIO()
1867
1880
def test_transform_conflicts(self):
1868
1881
revision_tree = self.create_tree()
1869
1882
preview = TransformPreview(revision_tree)
1883
self.addPreviewCleanup(preview)
1870
1884
preview.new_file('a', preview.root, 'content 2')
1871
1885
resolve_conflicts(preview)
1872
1886
trans_id = preview.trans_id_file_id('a-id')
1875
1889
def get_tree_and_preview_tree(self):
1876
1890
revision_tree = self.create_tree()
1877
1891
preview = TransformPreview(revision_tree)
1892
self.addPreviewCleanup(preview)
1878
1893
a_trans_id = preview.trans_id_file_id('a-id')
1879
1894
preview.delete_contents(a_trans_id)
1880
1895
preview.create_file('b content', a_trans_id)
1932
1947
def test_kind(self):
1933
1948
revision_tree = self.create_tree()
1934
1949
preview = TransformPreview(revision_tree)
1950
self.addPreviewCleanup(preview)
1935
1951
preview.new_file('file', preview.root, 'contents', 'file-id')
1936
1952
preview.new_directory('directory', preview.root, 'dir-id')
1937
1953
preview_tree = preview.get_preview_tree()