127
143
[(path, node.file_id) for path, node in tree.iter_entries_by_dir()])
128
144
self.assertEqualDiff('contents of a\n', tree.get_file_text('a-id'))
129
145
self.assertTrue(tree.is_executable('c-id'))
147
def test_tree_with_subdirs_and_all_content_types(self):
148
# currently this test tree requires unicode. It might be good
149
# to have it simply stop having the single unicode file in it
150
# when dealing with a non-unicode filesystem.
151
if not has_symlinks():
152
raise TestSkipped('No symlink support')
153
tree = self.get_tree_with_subdirs_and_all_content_types()
155
self.addCleanup(tree.unlock)
156
self.assertEqual([], tree.get_parent_ids())
157
self.assertEqual([], tree.conflicts())
158
self.assertEqual([], list(tree.unknowns()))
159
# __iter__ has no strongly defined order
160
tree_root = tree.path2id('')
167
u'0utf\u1234file'.encode('utf8'),
171
# note that the order of the paths and fileids is deliberately
172
# mismatched to ensure that the result order is path based.
174
[('', tree_root, 'directory'),
175
('0file', '2file', 'file'),
176
('1top-dir', '1top-dir', 'directory'),
177
(u'2utf\u1234file', u'0utf\u1234file'.encode('utf8'), 'file'),
178
('symlink', 'symlink', 'symlink'),
179
('1top-dir/0file-in-1topdir', '1file-in-1topdir', 'file'),
180
('1top-dir/1dir-in-1topdir', '0dir-in-1topdir', 'directory')],
181
[(path, node.file_id, node.kind) for path, node in tree.iter_entries_by_dir()])
183
def test_tree_with_subdirs_and_all_content_types_wo_symlinks(self):
184
# currently this test tree requires unicode. It might be good
185
# to have it simply stop having the single unicode file in it
186
# when dealing with a non-unicode filesystem.
187
tree = self.get_tree_with_subdirs_and_all_supported_content_types(False)
189
self.addCleanup(tree.unlock)
190
self.assertEqual([], tree.get_parent_ids())
191
self.assertEqual([], tree.conflicts())
192
self.assertEqual([], list(tree.unknowns()))
193
# __iter__ has no strongly defined order
194
tree_root = tree.path2id('')
201
u'0utf\u1234file'.encode('utf8'),
204
# note that the order of the paths and fileids is deliberately
205
# mismatched to ensure that the result order is path based.
207
[('', tree_root, 'directory'),
208
('0file', '2file', 'file'),
209
('1top-dir', '1top-dir', 'directory'),
210
(u'2utf\u1234file', u'0utf\u1234file'.encode('utf8'), 'file'),
211
('1top-dir/0file-in-1topdir', '1file-in-1topdir', 'file'),
212
('1top-dir/1dir-in-1topdir', '0dir-in-1topdir', 'directory')],
213
[(path, node.file_id, node.kind) for path, node in tree.iter_entries_by_dir()])
215
def test_tree_with_utf8(self):
216
tree = self.make_branch_and_tree('.')
217
tree = self.get_tree_with_utf8(tree)
219
revision_id = u'r\xe9v-1'.encode('utf8')
220
root_id = 'TREE_ROOT'
221
bar_id = u'b\xe5r-id'.encode('utf8')
222
foo_id = u'f\xf6-id'.encode('utf8')
223
baz_id = u'b\xe1z-id'.encode('utf8')
224
path_and_ids = [(u'', root_id, None),
225
(u'b\xe5r', bar_id, root_id),
226
(u'f\xf6', foo_id, root_id),
227
(u'b\xe5r/b\xe1z', baz_id, bar_id),
231
path_entries = list(tree.iter_entries_by_dir())
235
for expected, (path, ie) in zip(path_and_ids, path_entries):
236
self.assertEqual(expected[0], path) # Paths should match
237
self.assertIsInstance(path, unicode)
238
self.assertEqual(expected[1], ie.file_id)
239
self.assertIsInstance(ie.file_id, str)
240
self.assertEqual(expected[2], ie.parent_id)
241
if expected[2] is not None:
242
self.assertIsInstance(ie.parent_id, str)
243
# WorkingTree's return None for the last modified revision
244
if ie.revision is not None:
245
self.assertIsInstance(ie.revision, str)
246
if expected[0] != '':
247
# Some trees will preserve the revision id of the tree root,
249
self.assertEqual(revision_id, ie.revision)
250
self.assertEqual(len(path_and_ids), len(path_entries))
251
get_revision_id = getattr(tree, 'get_revision_id', None)
252
if get_revision_id is not None:
253
self.assertIsInstance(get_revision_id(), str)
254
last_revision = getattr(tree, 'last_revision', None)
255
if last_revision is not None:
256
self.assertIsInstance(last_revision(), str)
258
def test_tree_with_merged_utf8(self):
259
tree = self.make_branch_and_tree('.')
260
tree = self.get_tree_with_merged_utf8(tree)
262
revision_id_1 = u'r\xe9v-1'.encode('utf8')
263
revision_id_2 = u'r\xe9v-2'.encode('utf8')
264
root_id = 'TREE_ROOT'
265
bar_id = u'b\xe5r-id'.encode('utf8')
266
foo_id = u'f\xf6-id'.encode('utf8')
267
baz_id = u'b\xe1z-id'.encode('utf8')
268
zez_id = u'z\xf7z-id'.encode('utf8')
269
path_and_ids = [(u'', root_id, None, None),
270
(u'b\xe5r', bar_id, root_id, revision_id_1),
271
(u'f\xf6', foo_id, root_id, revision_id_1),
272
(u'b\xe5r/b\xe1z', baz_id, bar_id, revision_id_1),
273
(u'b\xe5r/z\xf7z', zez_id, bar_id, revision_id_2),
277
path_entries = list(tree.iter_entries_by_dir())
281
for expected, (path, ie) in zip(path_and_ids, path_entries):
282
self.assertEqual(expected[0], path) # Paths should match
283
self.assertIsInstance(path, unicode)
284
self.assertEqual(expected[1], ie.file_id)
285
self.assertIsInstance(ie.file_id, str)
286
self.assertEqual(expected[2], ie.parent_id)
287
if expected[2] is not None:
288
self.assertIsInstance(ie.parent_id, str)
289
# WorkingTree's return None for the last modified revision
290
if ie.revision is not None:
291
self.assertIsInstance(ie.revision, str)
292
if expected[0] == '':
293
# Some trees will preserve the revision id of the tree root,
296
self.assertEqual(expected[3], ie.revision)
297
self.assertEqual(len(path_and_ids), len(path_entries))
298
get_revision_id = getattr(tree, 'get_revision_id', None)
299
if get_revision_id is not None:
300
self.assertIsInstance(get_revision_id(), str)
301
last_revision = getattr(tree, 'last_revision', None)
302
if last_revision is not None:
303
self.assertIsInstance(last_revision(), str)