/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/tests/tree_implementations/__init__.py

Merge bzr.dev.

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
    )
57
57
 
58
58
 
59
 
def return_parameter(something):
 
59
def return_parameter(testcase, something):
60
60
    """A trivial thunk to return its input."""
61
61
    return something
62
62
 
63
63
 
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)
68
68
 
69
69
 
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()
73
73
 
76
76
 
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)
81
81
 
82
82
 
89
89
        made_control.create_branch()
90
90
        return self.workingtree_format.initialize(made_control)
91
91
 
 
92
    def workingtree_to_test_tree(self, tree):
 
93
        return self._workingtree_to_test_tree(self, tree)
 
94
 
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
307
 
        # code.
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
313
 
 
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,))
 
311
 
 
312
        # also test WorkingTree4's RevisionTree implementation which is
 
313
        # specialised.
 
314
        self.scenarios.append(self.create_tree_scenario(
 
315
            DirStateRevisionTree.__name__, _dirstate_tree_from_workingtree,
 
316
            WorkingTreeFormat4()))
 
317
 
 
318
    def create_tree_scenario(self, name, converter, workingtree_format=None):
 
319
        """Create a scenario for the specified converter
 
320
 
 
321
        :param name: The name to append to tests using this converter
 
322
        :param converter: A function that converts a workingtree into the
 
323
            desired format.
 
324
        :param workingtree_format: The particular workingtree format to
 
325
            convert from.
 
326
        :return: a (name, options) tuple, where options is a dict of values
 
327
            to be used as members of the TestCase.
 
328
        """
 
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
320
335
 
321
336
 
322
337
def test_suite():