23
23
so these tests are testing that when there is a cache, it performs correctly.
26
from bzrlib import errors
27
from bzrlib.tests.per_workingtree import TestCaseWithWorkingTree
30
class TestRevisionTree(TestCaseWithWorkingTree):
31
from bzrlib.tests import per_workingtree
34
class TestRevisionTree(per_workingtree.TestCaseWithWorkingTree):
32
36
def test_get_zeroth_basis_tree_via_revision_tree(self):
33
37
tree = self.make_branch_and_tree('.')
84
88
repository_revision_tree = tree.branch.repository.revision_tree(rev1)
85
89
self.assertTreesEqual(repository_revision_tree, cached_revision_tree)
92
class TestRevisionTreeKind(per_workingtree.TestCaseWithWorkingTree):
94
def make_branch_with_merged_deletions(self, relpath='tree'):
95
tree = self.make_branch_and_tree(relpath)
96
files = ['a', 'b/', 'b/c']
97
self.build_tree(files, line_endings='binary',
98
transport=tree.bzrdir.root_transport)
99
tree.set_root_id('root-id')
100
tree.add(files, ['a-id', 'b-id', 'c-id'])
101
tree.commit('a, b and b/c', rev_id='base')
102
tree2 = tree.bzrdir.sprout(relpath + '2').open_workingtree()
104
tree.remove('a', keep_files=False)
105
tree.commit('remove a', rev_id='this')
106
# Delete 'c' in tree2
107
tree2.remove('b/c', keep_files=False)
108
tree2.remove('b', keep_files=False)
109
tree2.commit('remove b/c', rev_id='other')
110
# Merge tree2 into tree
111
tree.merge_from_branch(tree2.branch)
114
def test_kind_parent_tree(self):
115
tree = self.make_branch_with_merged_deletions()
117
self.addCleanup(tree.unlock)
118
parents = tree.get_parent_ids()
119
self.assertEqual(['this', 'other'], parents)
120
basis = tree.revision_tree(parents[0])
122
self.addCleanup(basis.unlock)
123
self.assertRaises(errors.NoSuchId, basis.kind, 'a-id')
124
self.assertEqual(['directory', 'file'],
125
[basis.kind('b-id'), basis.kind('c-id')])
127
other = tree.revision_tree(parents[1])
128
except errors.NoSuchRevisionInTree:
129
raise tests.TestNotApplicable(
130
'Tree type %s caches only the basis revision tree.'
133
self.addCleanup(other.unlock)
134
self.assertRaises(errors.NoSuchId, other.kind, 'b-id')
135
self.assertRaises(errors.NoSuchId, other.kind, 'c-id')
136
self.assertEqual('file', other.kind('a-id'))