1
# Copyright (C) 2006 Canonical Ltd
1
# Copyright (C) 2006, 2009 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
15
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
18
"""InterTree implementation tests for bzr.
49
54
class TestCaseWithTwoTrees(TestCaseWithTree):
56
def not_applicable_if_cannot_represent_unversioned(self, tree):
57
if isinstance(tree, revisiontree.RevisionTree):
58
# The locked test trees conversion could not preserve the
59
# unversioned file status. This is normal (e.g. InterDirstateTree
60
# falls back to InterTree if the basis is not a
61
# DirstateRevisionTree, and revision trees cannot have unversioned
63
raise tests.TestNotApplicable('cannot represent unversioned files')
65
def not_applicable_if_missing_in(self, relpath, tree):
66
if not tree.path2id(relpath):
67
# The locked test trees conversion could not preserve the missing
68
# file status. This is normal (e.g. InterDirstateTree falls back
69
# to InterTree if the basis is not a DirstateRevisionTree, and
70
# revision trees cannot have missing files.
71
raise tests.TestNotApplicable('cannot represent missing files')
51
73
def make_to_branch_and_tree(self, relpath):
52
74
"""Make a to_workingtree_format branch and tree."""
53
75
made_control = self.make_bzrdir(relpath,
94
116
test_case.addCleanup(preview.finalize)
95
117
return source, preview.get_preview_tree()
119
def mutable_trees_to_revision_trees(test_case, source, target):
120
"""Convert both trees to repository based revision trees."""
121
return (revision_tree_from_workingtree(test_case, source),
122
revision_tree_from_workingtree(test_case, target))
98
125
def load_tests(standard_tests, module, loader):
99
126
default_tree_format = WorkingTreeFormat3()
103
130
test_intertree_permutations = [
104
131
# test InterTree with two default-format working trees.
105
(InterTree.__name__, InterTree, default_tree_format, default_tree_format,
132
(InterTree.__name__, InterTree,
133
default_tree_format, default_tree_format,
106
134
return_provided_trees)]
107
135
for optimiser in InterTree._optimisers:
108
if optimiser is bzrlib.workingtree_4.InterDirStateTree:
136
if optimiser is revisiontree.InterCHKRevisionTree:
137
# XXX: we shouldn't use an Intertree object to detect inventories
139
chk_tree_format = WorkingTreeFormat4()
140
chk_tree_format._get_matchingbzrdir = \
141
lambda:bzrlib.bzrdir.format_registry.make_bzrdir(
142
'development6-rich-root')
143
test_intertree_permutations.append(
144
(InterTree.__name__ + "(CHKInventory)",
148
mutable_trees_to_revision_trees))
149
elif optimiser is bzrlib.workingtree_4.InterDirStateTree:
109
150
# Its a little ugly to be conditional here, but less so than having
110
151
# the optimiser listed twice.
111
152
# Add once, compiled version