~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Brad Crittenden
  • Date: 2007-02-26 20:56:10 UTC
  • mfrom: (2300 +trunk)
  • mto: (2293.1.5 bzr.dev)
  • mto: This revision was merged to the branch mainline in revision 2311.
  • Revision ID: brad.crittenden@canonical.com-20070226205610-44oatbxrjjz3ajwy
merge

Show diffs side-by-side

added added

removed removed

Lines of Context:
127
127
            [(path, node.file_id) for path, node in tree.iter_entries_by_dir()])
128
128
        self.assertEqualDiff('contents of a\n', tree.get_file_text('a-id'))
129
129
        self.assertTrue(tree.is_executable('c-id'))
 
130
 
 
131
    def test_tree_with_utf8(self):
 
132
        tree = self.make_branch_and_tree('.')
 
133
        tree = self.get_tree_with_utf8(tree)
 
134
 
 
135
        revision_id = u'r\xe9v-1'.encode('utf8')
 
136
        root_id = 'TREE_ROOT'
 
137
        bar_id = u'b\xe5r-id'.encode('utf8')
 
138
        foo_id = u'f\xf6-id'.encode('utf8')
 
139
        baz_id = u'b\xe1z-id'.encode('utf8')
 
140
        path_and_ids = [(u'', root_id, None),
 
141
                        (u'b\xe5r', bar_id, root_id),
 
142
                        (u'f\xf6', foo_id, root_id),
 
143
                        (u'b\xe5r/b\xe1z', baz_id, bar_id),
 
144
                       ]
 
145
        tree.lock_read()
 
146
        try:
 
147
            path_entries = list(tree.iter_entries_by_dir())
 
148
        finally:
 
149
            tree.unlock()
 
150
 
 
151
        for expected, (path, ie) in zip(path_and_ids, path_entries):
 
152
            self.assertEqual(expected[0], path) # Paths should match
 
153
            self.assertIsInstance(path, unicode)
 
154
            self.assertEqual(expected[1], ie.file_id)
 
155
            self.assertIsInstance(ie.file_id, str)
 
156
            self.assertEqual(expected[2], ie.parent_id)
 
157
            if expected[2] is not None:
 
158
                self.assertIsInstance(ie.parent_id, str)
 
159
            # WorkingTree's return None for the last modified revision
 
160
            if ie.revision is not None:
 
161
                self.assertIsInstance(ie.revision, str)
 
162
                if expected[0] != '':
 
163
                    # Some trees will preserve the revision id of the tree root,
 
164
                    # but not all will
 
165
                    self.assertEqual(revision_id, ie.revision)
 
166
        self.assertEqual(len(path_and_ids), len(path_entries))
 
167
        get_revision_id = getattr(tree, 'get_revision_id', None)
 
168
        if get_revision_id is not None:
 
169
            self.assertIsInstance(get_revision_id(), str)
 
170
        last_revision = getattr(tree, 'last_revision', None)
 
171
        if last_revision is not None:
 
172
            self.assertIsInstance(last_revision(), str)
 
173
 
 
174
    def test_tree_with_merged_utf8(self):
 
175
        tree = self.make_branch_and_tree('.')
 
176
        tree = self.get_tree_with_merged_utf8(tree)
 
177
 
 
178
        revision_id_1 = u'r\xe9v-1'.encode('utf8')
 
179
        revision_id_2 = u'r\xe9v-2'.encode('utf8')
 
180
        root_id = 'TREE_ROOT'
 
181
        bar_id = u'b\xe5r-id'.encode('utf8')
 
182
        foo_id = u'f\xf6-id'.encode('utf8')
 
183
        baz_id = u'b\xe1z-id'.encode('utf8')
 
184
        zez_id = u'z\xf7z-id'.encode('utf8')
 
185
        path_and_ids = [(u'', root_id, None, None),
 
186
                        (u'b\xe5r', bar_id, root_id, revision_id_1),
 
187
                        (u'f\xf6', foo_id, root_id, revision_id_1),
 
188
                        (u'b\xe5r/b\xe1z', baz_id, bar_id, revision_id_1),
 
189
                        (u'b\xe5r/z\xf7z', zez_id, bar_id, revision_id_2),
 
190
                       ]
 
191
        tree.lock_read()
 
192
        try:
 
193
            path_entries = list(tree.iter_entries_by_dir())
 
194
        finally:
 
195
            tree.unlock()
 
196
 
 
197
        for expected, (path, ie) in zip(path_and_ids, path_entries):
 
198
            self.assertEqual(expected[0], path) # Paths should match
 
199
            self.assertIsInstance(path, unicode)
 
200
            self.assertEqual(expected[1], ie.file_id)
 
201
            self.assertIsInstance(ie.file_id, str)
 
202
            self.assertEqual(expected[2], ie.parent_id)
 
203
            if expected[2] is not None:
 
204
                self.assertIsInstance(ie.parent_id, str)
 
205
            # WorkingTree's return None for the last modified revision
 
206
            if ie.revision is not None:
 
207
                self.assertIsInstance(ie.revision, str)
 
208
                if expected[0] == '':
 
209
                    # Some trees will preserve the revision id of the tree root,
 
210
                    # but not all will
 
211
                    continue
 
212
                self.assertEqual(expected[3], ie.revision)
 
213
        self.assertEqual(len(path_and_ids), len(path_entries))
 
214
        get_revision_id = getattr(tree, 'get_revision_id', None)
 
215
        if get_revision_id is not None:
 
216
            self.assertIsInstance(get_revision_id(), str)
 
217
        last_revision = getattr(tree, 'last_revision', None)
 
218
        if last_revision is not None:
 
219
            self.assertIsInstance(last_revision(), str)