Rev 2297: Make sure the inventory enrtries returned are properly formed. in http://bzr.arbash-meinel.com/branches/bzr/0.15-dev/utf8_file_ids
John Arbash Meinel
john at arbash-meinel.com
Sat Feb 17 21:13:03 GMT 2007
At http://bzr.arbash-meinel.com/branches/bzr/0.15-dev/utf8_file_ids
------------------------------------------------------------
revno: 2297
revision-id: john at arbash-meinel.com-20070217211255-kzskwwv9rukq6r7r
parent: john at arbash-meinel.com-20070217185558-mhsvsed3azztcuez
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: utf8_file_ids
timestamp: Sat 2007-02-17 15:12:55 -0600
message:
Make sure the inventory enrtries returned are properly formed.
modified:
bzrlib/tests/tree_implementations/__init__.py __init__.py-20060717075546-420s7b0bj9hzeowi-2
bzrlib/tests/tree_implementations/test_test_trees.py test_tree_trees.py-20060720091921-3nwi5h21lf06vf5p-1
-------------- next part --------------
=== modified file 'bzrlib/tests/tree_implementations/__init__.py'
--- a/bzrlib/tests/tree_implementations/__init__.py 2007-02-17 18:55:58 +0000
+++ b/bzrlib/tests/tree_implementations/__init__.py 2007-02-17 21:12:55 +0000
@@ -172,18 +172,20 @@
def _create_tree_with_utf8(self, tree):
"""Generate a tree with a utf8 revision and unicode paths."""
- paths = [u'f\xf6',
+ paths = [u'',
+ u'f\xf6',
u'b\xe5r/',
u'b\xe5r/b\xe1z',
]
# bzr itself does not create unicode file ids, but we want them for
# testing.
- file_ids = [u'f\xf6-id',
+ file_ids = [u'TREE_ROOT',
+ u'f\xf6-id',
u'b\xe5-r-id',
u'b\xe1z-id',
]
try:
- self.build_tree(paths)
+ self.build_tree(paths[1:])
except UnicodeError:
raise tests.TestSkipped('filesystem does not support unicode.')
tree.add(paths, file_ids)
=== modified file 'bzrlib/tests/tree_implementations/test_test_trees.py'
--- a/bzrlib/tests/tree_implementations/test_test_trees.py 2007-02-17 18:55:58 +0000
+++ b/bzrlib/tests/tree_implementations/test_test_trees.py 2007-02-17 21:12:55 +0000
@@ -132,6 +132,80 @@
tree = self.make_branch_and_tree('.')
tree = self.get_tree_with_utf8(tree)
+ revision_id = u'r\xe9v-1'.encode('utf8')
+ path_and_ids = [(u'', u'TREE_ROOT'),
+ (u'b\xe5r', u'b\xe5-r-id'),
+ (u'f\xf6', u'f\xf6-id'),
+ (u'b\xe5r/b\xe1z', u'b\xe1z-id'),
+ ]
+ tree.lock_read()
+ try:
+ path_entries = list(tree.iter_entries_by_dir())
+ finally:
+ tree.unlock()
+
+ for expected, actual in zip(path_and_ids, path_entries):
+ self.assertEqual(expected[0], actual[0]) # Paths should match
+ self.assertEqual(expected[1], actual[1].file_id)
+ if isinstance(actual[1].file_id, str):
+ # file_ids might be plain strings, but only if they are ascii
+ actual[1].file_id.decode('ascii')
+ else:
+ self.assertIsInstance(actual[1].file_id, unicode)
+ # WorkingTree's return None for the last modified revision
+ if actual[1].revision is not None:
+ self.assertIsInstance(actual[1].revision, str)
+ if expected[0] == '':
+ # Some trees will preserve the revision id of the tree root,
+ # but not all will
+ continue
+ self.assertEqual(revision_id, actual[1].revision)
+ self.assertEqual(len(path_and_ids), len(path_entries))
+ get_revision_id = getattr(tree, 'get_revision_id', None)
+ if get_revision_id is not None:
+ self.assertIsInstance(get_revision_id(), str)
+ last_revision = getattr(tree, 'last_revision', None)
+ if last_revision is not None:
+ self.assertIsInstance(last_revision(), str)
+
def test_tree_with_merged_utf8(self):
tree = self.make_branch_and_tree('.')
tree = self.get_tree_with_merged_utf8(tree)
+
+ revision_id_1 = u'r\xe9v-1'.encode('utf8')
+ revision_id_2 = u'r\xe9v-2'.encode('utf8')
+ path_and_ids = [(u'', u'TREE_ROOT', None),
+ (u'b\xe5r', u'b\xe5-r-id', revision_id_1),
+ (u'f\xf6', u'f\xf6-id', revision_id_1),
+ (u'b\xe5r/b\xe1z', u'b\xe1z-id', revision_id_1),
+ (u'b\xe5r/z\xf7z', u'z\xf7z-id', revision_id_2),
+ ]
+ tree.lock_read()
+ try:
+ path_entries = list(tree.iter_entries_by_dir())
+ finally:
+ tree.unlock()
+
+ for expected, actual in zip(path_and_ids, path_entries):
+ self.assertEqual(expected[0], actual[0]) # Paths should match
+ self.assertEqual(expected[1], actual[1].file_id)
+ if isinstance(actual[1].file_id, str):
+ # file_ids might be plain strings, but only if they are ascii
+ actual[1].file_id.decode('ascii')
+ else:
+ self.assertIsInstance(actual[1].file_id, unicode)
+ # WorkingTree's return None for the last modified revision
+ if actual[1].revision is not None:
+ self.assertIsInstance(actual[1].revision, str)
+ if expected[0] == '':
+ # Some trees will preserve the revision id of the tree root,
+ # but not all will
+ continue
+ self.assertEqual(expected[2], actual[1].revision)
+ self.assertEqual(len(path_and_ids), len(path_entries))
+ get_revision_id = getattr(tree, 'get_revision_id', None)
+ if get_revision_id is not None:
+ self.assertIsInstance(get_revision_id(), str)
+ last_revision = getattr(tree, 'last_revision', None)
+ if last_revision is not None:
+ self.assertIsInstance(last_revision(), str)
More information about the bazaar-commits
mailing list