~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Robert Collins
  • Date: 2006-07-25 06:19:05 UTC
  • mto: (1852.7.4 split-tree-source)
  • mto: This revision was merged to the branch mainline in revision 1890.
  • Revision ID: robertc@robertcollins.net-20060725061905-b1ab0530dcca0238
Add more test trees to the tree-implementations tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
25
25
 - tests/workingtree_implementations/*.py.
26
26
"""
27
27
 
28
 
import bzrlib.errors as errors
 
28
from bzrlib import (
 
29
    errors,
 
30
    transform,
 
31
    )
29
32
from bzrlib.transport import get_transport
30
33
from bzrlib.tests import (
31
34
                          adapt_modules,
75
78
        # convert that to the final shape
76
79
        return self.workingtree_to_test_tree(tree)
77
80
 
 
81
    def _make_abc_tree(self, tree):
 
82
        """setup an abc content tree."""
 
83
        files = ['a', 'b/', 'b/c']
 
84
        self.build_tree(files, transport=tree.bzrdir.root_transport)
 
85
        tree.add(files, ['a-id', 'b-id', 'c-id'])
 
86
 
 
87
    def get_tree_no_parents_abc_content(self):
 
88
        """return a test tree with a, b/, b/c contents."""
 
89
        tree = self.make_branch_and_tree('.')
 
90
        self._make_abc_tree(tree)
 
91
        return self.workingtree_to_test_tree(tree)
 
92
 
 
93
    def get_tree_no_parents_abc_content_2(self):
 
94
        """return a test tree with a, b/, b/c contents.
 
95
        
 
96
        This variation changes the content of 'a' to foobar\n.
 
97
        """
 
98
        tree = self.make_branch_and_tree('.')
 
99
        self._make_abc_tree(tree)
 
100
        f = open(tree.basedir + '/a', 'wb')
 
101
        try:
 
102
            f.write('foobar\n')
 
103
        finally:
 
104
            f.close()
 
105
        return self.workingtree_to_test_tree(tree)
 
106
 
 
107
    def get_tree_no_parents_abc_content_3(self):
 
108
        """return a test tree with a, b/, b/c contents.
 
109
        
 
110
        This variation changes the executable flag of b/c to True.
 
111
        """
 
112
        tree = self.make_branch_and_tree('.')
 
113
        self._make_abc_tree(tree)
 
114
        tt = transform.TreeTransform(tree)
 
115
        trans_id = tt.trans_id_tree_path('b/c')
 
116
        tt.set_executability(True, trans_id)
 
117
        tt.apply()
 
118
        return self.workingtree_to_test_tree(tree)
 
119
 
 
120
    def get_tree_no_parents_abc_content_4(self):
 
121
        """return a test tree with d, b/, b/c contents.
 
122
        
 
123
        This variation renames a to d.
 
124
        """
 
125
        tree = self.make_branch_and_tree('.')
 
126
        self._make_abc_tree(tree)
 
127
        tree.rename_one('a', 'd')
 
128
        return self.workingtree_to_test_tree(tree)
 
129
 
 
130
    def get_tree_no_parents_abc_content_5(self):
 
131
        """return a test tree with d, b/, b/c contents.
 
132
        
 
133
        This variation renames a to d and alters its content to 'bar\n'.
 
134
        """
 
135
        tree = self.make_branch_and_tree('.')
 
136
        self._make_abc_tree(tree)
 
137
        tree.rename_one('a', 'd')
 
138
        f = open(tree.basedir + '/d', 'wb')
 
139
        try:
 
140
            f.write('bar\n')
 
141
        finally:
 
142
            f.close()
 
143
        return self.workingtree_to_test_tree(tree)
 
144
 
 
145
    def get_tree_no_parents_abc_content_6(self):
 
146
        """return a test tree with a, b/, e contents.
 
147
        
 
148
        This variation renames b/c to e, and makes it executable.
 
149
        """
 
150
        tree = self.make_branch_and_tree('.')
 
151
        self._make_abc_tree(tree)
 
152
        tt = transform.TreeTransform(tree)
 
153
        trans_id = tt.trans_id_tree_path('b/c')
 
154
        parent_trans_id = tt.trans_id_tree_path('')
 
155
        tt.adjust_path('e', parent_trans_id, trans_id)
 
156
        tt.set_executability(True, trans_id)
 
157
        tt.apply()
 
158
        return self.workingtree_to_test_tree(tree)
 
159
 
78
160
 
79
161
class TreeTestProviderAdapter(WorkingTreeTestProviderAdapter):
80
162
    """Generate test suites for each Tree implementation in bzrlib.