59
def return_parameter(something):
59
def return_parameter(testcase, something):
60
60
"""A trivial thunk to return its input."""
64
def revision_tree_from_workingtree(tree):
64
def revision_tree_from_workingtree(testcase, tree):
65
65
"""Create a revision tree from a working tree."""
66
66
revid = tree.commit('save tree', allow_pointless=True, recursive=None)
67
67
return tree.branch.repository.revision_tree(revid)
70
def _dirstate_tree_from_workingtree(tree):
70
def _dirstate_tree_from_workingtree(testcase, tree):
71
71
revid = tree.commit('save tree', allow_pointless=True)
72
72
return tree.basis_tree()
77
77
def test_revision_tree_from_workingtree(self):
78
78
tree = self.make_branch_and_tree('.')
79
tree = revision_tree_from_workingtree(tree)
79
tree = revision_tree_from_workingtree(self, tree)
80
80
self.assertIsInstance(tree, RevisionTree)
89
89
made_control.create_branch()
90
90
return self.workingtree_format.initialize(made_control)
92
def workingtree_to_test_tree(self, tree):
93
return self._workingtree_to_test_tree(self, tree)
92
95
def _convert_tree(self, tree, converter=None):
93
96
"""helper to convert using the converter or a supplied one."""
94
97
# convert that to the final shape
301
304
# now adjust the scenarios and add the non-working-tree tree scenarios.
302
305
for scenario in self.scenarios:
303
306
# for working tree adapted tests, preserve the tree
304
scenario[1]["workingtree_to_test_tree"] = return_parameter
307
scenario[1]["_workingtree_to_test_tree"] = return_parameter
305
308
# add RevisionTree scenario
306
# this is the 'default format' in that it's used to test the generic InterTree
308
default_format = WorkingTreeFormat3()
309
self.scenarios.append(self.formats_to_scenarios([
310
(default_format, default_format._matchingbzrdir)])[0])
311
self.scenarios[-1] = (RevisionTree.__name__, self.scenarios[-1][1])
312
self.scenarios[-1][1]["workingtree_to_test_tree"] = revision_tree_from_workingtree
314
# also test WorkingTree4's RevisionTree implementation which is specialised.
315
dirstate_format = WorkingTreeFormat4()
316
self.scenarios.append(self.formats_to_scenarios([
317
(dirstate_format, dirstate_format._matchingbzrdir)])[0])
318
self.scenarios[-1] = (DirStateRevisionTree.__name__, self.scenarios[-1][1])
319
self.scenarios[-1][1]["workingtree_to_test_tree"] = _dirstate_tree_from_workingtree
309
self.scenarios.append(self.create_tree_scenario(RevisionTree.__name__,
310
revision_tree_from_workingtree,))
312
# also test WorkingTree4's RevisionTree implementation which is
314
self.scenarios.append(self.create_tree_scenario(
315
DirStateRevisionTree.__name__, _dirstate_tree_from_workingtree,
316
WorkingTreeFormat4()))
318
def create_tree_scenario(self, name, converter, workingtree_format=None):
319
"""Create a scenario for the specified converter
321
:param name: The name to append to tests using this converter
322
:param converter: A function that converts a workingtree into the
324
:param workingtree_format: The particular workingtree format to
326
:return: a (name, options) tuple, where options is a dict of values
327
to be used as members of the TestCase.
329
if workingtree_format is None:
330
workingtree_format = WorkingTreeFormat3()
331
scenario_options = WorkingTreeTestProviderAdapter.create_scenario(self,
332
workingtree_format, workingtree_format._matchingbzrdir)[1]
333
scenario_options["_workingtree_to_test_tree"] = converter
334
return name, scenario_options
322
337
def test_suite():