/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/intertree_implementations/__init__.py

  • Committer: Robert Collins
  • Date: 2009-05-23 20:57:12 UTC
  • mfrom: (4371 +trunk)
  • mto: This revision was merged to the branch mainline in revision 4441.
  • Revision ID: robertc@robertcollins.net-20090523205712-lcwbfqk6vwavinuv
MergeĀ .dev.

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
12
12
#
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
16
16
 
17
17
 
18
18
"""InterTree implementation tests for bzr.
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(
 
142
                    'development6-rich-root')
 
143
            test_intertree_permutations.append(
 
144
                (InterTree.__name__ + "(CHKInventory)",
 
145
                 InterTree,
 
146
                 chk_tree_format,
 
147
                 chk_tree_format,
 
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