/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

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-07-29 04:13:57 UTC
  • mfrom: (1852.8.9 InterTree)
  • Revision ID: pqm@pqm.ubuntu.com-20060729041357-afd38d0f2ec38ae4
(robertc) Add InterTree with interface conformance tests. InterTree representions actions between Trees.

Show diffs side-by-side

added added

removed removed

Lines of Context:
66
66
 
67
67
class TestCaseWithTree(TestCaseWithBzrDir):
68
68
 
69
 
    def make_branch_and_tree(self, relpath, format=None):
70
 
        made_control = self.make_bzrdir(relpath, format=format)
 
69
    def make_branch_and_tree(self, relpath):
 
70
        made_control = self.make_bzrdir(relpath, format=
 
71
            self.workingtree_format._matchingbzrdir)
71
72
        made_control.create_repository()
72
73
        made_control.create_branch()
73
74
        return self.workingtree_format.initialize(made_control)
74
75
 
75
 
    def get_tree_no_parents_no_content(self):
76
 
        # make a working tree with the right shape
77
 
        tree = self.make_branch_and_tree('.')
 
76
    def _convert_tree(self, tree, converter=None):
 
77
        """helper to convert using the converter or a supplied one."""
78
78
        # convert that to the final shape
79
 
        return self.workingtree_to_test_tree(tree)
 
79
        if converter is None:
 
80
            converter = self.workingtree_to_test_tree
 
81
        return converter(tree)
 
82
 
 
83
    def get_tree_no_parents_no_content(self, empty_tree, converter=None):
 
84
        """Make a tree with no parents and no contents from empty_tree.
 
85
        
 
86
        :param empty_tree: A working tree with no content and no parents to
 
87
            modify.
 
88
        """
 
89
        return self._convert_tree(empty_tree, converter)
80
90
 
81
91
    def _make_abc_tree(self, tree):
82
92
        """setup an abc content tree."""
84
94
        self.build_tree(files, transport=tree.bzrdir.root_transport)
85
95
        tree.add(files, ['a-id', 'b-id', 'c-id'])
86
96
 
87
 
    def get_tree_no_parents_abc_content(self):
 
97
    def get_tree_no_parents_abc_content(self, tree, converter=None):
88
98
        """return a test tree with a, b/, b/c contents."""
89
 
        tree = self.make_branch_and_tree('.')
90
99
        self._make_abc_tree(tree)
91
 
        return self.workingtree_to_test_tree(tree)
 
100
        return self._convert_tree(tree, converter)
92
101
 
93
 
    def get_tree_no_parents_abc_content_2(self):
 
102
    def get_tree_no_parents_abc_content_2(self, tree, converter=None):
94
103
        """return a test tree with a, b/, b/c contents.
95
104
        
96
105
        This variation changes the content of 'a' to foobar\n.
97
106
        """
98
 
        tree = self.make_branch_and_tree('.')
99
107
        self._make_abc_tree(tree)
100
108
        f = open(tree.basedir + '/a', 'wb')
101
109
        try:
102
110
            f.write('foobar\n')
103
111
        finally:
104
112
            f.close()
105
 
        return self.workingtree_to_test_tree(tree)
 
113
        return self._convert_tree(tree, converter)
106
114
 
107
 
    def get_tree_no_parents_abc_content_3(self):
 
115
    def get_tree_no_parents_abc_content_3(self, tree, converter=None):
108
116
        """return a test tree with a, b/, b/c contents.
109
117
        
110
118
        This variation changes the executable flag of b/c to True.
111
119
        """
112
 
        tree = self.make_branch_and_tree('.')
113
120
        self._make_abc_tree(tree)
114
121
        tt = transform.TreeTransform(tree)
115
122
        trans_id = tt.trans_id_tree_path('b/c')
116
123
        tt.set_executability(True, trans_id)
117
124
        tt.apply()
118
 
        return self.workingtree_to_test_tree(tree)
 
125
        return self._convert_tree(tree, converter)
119
126
 
120
 
    def get_tree_no_parents_abc_content_4(self):
 
127
    def get_tree_no_parents_abc_content_4(self, tree, converter=None):
121
128
        """return a test tree with d, b/, b/c contents.
122
129
        
123
130
        This variation renames a to d.
124
131
        """
125
 
        tree = self.make_branch_and_tree('.')
126
132
        self._make_abc_tree(tree)
127
133
        tree.rename_one('a', 'd')
128
 
        return self.workingtree_to_test_tree(tree)
 
134
        return self._convert_tree(tree, converter)
129
135
 
130
 
    def get_tree_no_parents_abc_content_5(self):
 
136
    def get_tree_no_parents_abc_content_5(self, tree, converter=None):
131
137
        """return a test tree with d, b/, b/c contents.
132
138
        
133
139
        This variation renames a to d and alters its content to 'bar\n'.
134
140
        """
135
 
        tree = self.make_branch_and_tree('.')
136
141
        self._make_abc_tree(tree)
137
142
        tree.rename_one('a', 'd')
138
143
        f = open(tree.basedir + '/d', 'wb')
140
145
            f.write('bar\n')
141
146
        finally:
142
147
            f.close()
143
 
        return self.workingtree_to_test_tree(tree)
 
148
        return self._convert_tree(tree, converter)
144
149
 
145
 
    def get_tree_no_parents_abc_content_6(self):
 
150
    def get_tree_no_parents_abc_content_6(self, tree, converter=None):
146
151
        """return a test tree with a, b/, e contents.
147
152
        
148
153
        This variation renames b/c to e, and makes it executable.
149
154
        """
150
 
        tree = self.make_branch_and_tree('.')
151
155
        self._make_abc_tree(tree)
152
156
        tt = transform.TreeTransform(tree)
153
157
        trans_id = tt.trans_id_tree_path('b/c')
155
159
        tt.adjust_path('e', parent_trans_id, trans_id)
156
160
        tt.set_executability(True, trans_id)
157
161
        tt.apply()
158
 
        return self.workingtree_to_test_tree(tree)
 
162
        return self._convert_tree(tree, converter)
159
163
 
160
164
 
161
165
class TreeTestProviderAdapter(WorkingTreeTestProviderAdapter):