~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2009-04-07 08:11:19 UTC
  • mfrom: (4241.6.7 integration)
  • Revision ID: pqm@pqm.ubuntu.com-20090407081119-1sok81r9ekyriw0y
(robertc) Add InterCHKRevisionTree. (Vincent Ladeuil)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006 Canonical Ltd
 
1
# Copyright (C) 2006, 2009 Canonical Ltd
2
2
#
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
23
23
"""
24
24
 
25
25
import bzrlib
26
 
import bzrlib.errors as errors
 
26
from bzrlib import (
 
27
    errors,
 
28
    revisiontree,
 
29
    tests,
 
30
    )
27
31
from bzrlib.transport import get_transport
28
32
from bzrlib.transform import TransformPreview
29
33
from bzrlib.tests import (
39
43
from bzrlib.workingtree import (
40
44
    WorkingTreeFormat3,
41
45
    )
 
46
from bzrlib.workingtree_4 import WorkingTreeFormat4
42
47
 
43
48
 
44
49
def return_provided_trees(test_case, source, target):
48
53
 
49
54
class TestCaseWithTwoTrees(TestCaseWithTree):
50
55
 
 
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
 
62
            # files.
 
63
            raise tests.TestNotApplicable('cannot represent unversioned files')
 
64
 
 
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')
 
72
 
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()
96
118
 
 
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))
 
123
 
97
124
 
98
125
def load_tests(standard_tests, module, loader):
99
126
    default_tree_format = WorkingTreeFormat3()
102
129
        ])
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
 
138
            # -- vila 20090311
 
139
            chk_tree_format = WorkingTreeFormat4()
 
140
            chk_tree_format._get_matchingbzrdir = \
 
141
                lambda:bzrlib.bzrdir.format_registry.make_bzrdir('development')
 
142
            test_intertree_permutations.append(
 
143
                (InterTree.__name__ + "(CHKInventory)",
 
144
                 InterTree,
 
145
                 chk_tree_format,
 
146
                 chk_tree_format,
 
147
                 mutable_trees_to_revision_trees))
 
148
        elif optimiser is bzrlib.workingtree_4.InterDirStateTree:
109
149
            # Its a little ugly to be conditional here, but less so than having
110
150
            # the optimiser listed twice.
111
151
            # Add once, compiled version