Rev 2296: Track down and add tests that all tree.commit() can handle 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 18:56:06 GMT 2007
At http://bzr.arbash-meinel.com/branches/bzr/0.15-dev/utf8_file_ids
------------------------------------------------------------
revno: 2296
revision-id: john at arbash-meinel.com-20070217185558-mhsvsed3azztcuez
parent: john at arbash-meinel.com-20070217172506-ps0riemt041fkz0q
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: utf8_file_ids
timestamp: Sat 2007-02-17 12:55:58 -0600
message:
Track down and add tests that all tree.commit() can handle
non-ascii revision ids, as well as that file_ids_affected_by can handle
non-ascii revision ids. Also track down pending-merges needing to
write byte streams rather than unicode.
modified:
bzrlib/repository.py rev_storage.py-20051111201905-119e9401e46257e3
bzrlib/tests/repository_implementations/test_fileid_involved.py test_file_involved.py-20051215205901-728a172d1014daaa
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
bzrlib/workingtree.py workingtree.py-20050511021032-29b6ec0a681e02e3
-------------- next part --------------
=== modified file 'bzrlib/repository.py'
--- a/bzrlib/repository.py 2007-02-17 01:42:57 +0000
+++ b/bzrlib/repository.py 2007-02-17 18:55:58 +0000
@@ -544,7 +544,11 @@
try:
revision_id = unescape_revid_cache[revision_id]
except KeyError:
- unescaped = unescape(revision_id)
+ # TODO: jam 20070217 For now, _unescape_xml return Unicode
+ # revision ids, once we make file_ids utf8, then it
+ # will return utf8 strings instead, and we can get
+ # rid of this.
+ unescaped = osutils.safe_revision_id(unescape(revision_id))
unescape_revid_cache[revision_id] = unescaped
revision_id = unescaped
@@ -2081,7 +2085,13 @@
def _unescaper(match, _map=_unescape_map):
- return _map[match.group(1)]
+ code = match.group(1)
+ try:
+ return _map[code]
+ except KeyError:
+ if not code.startswith('#'):
+ raise
+ return unichr(int(code[1:]))
_unescape_re = None
=== modified file 'bzrlib/tests/repository_implementations/test_fileid_involved.py'
--- a/bzrlib/tests/repository_implementations/test_fileid_involved.py 2006-10-16 01:50:48 +0000
+++ b/bzrlib/tests/repository_implementations/test_fileid_involved.py 2007-02-17 18:55:58 +0000
@@ -19,7 +19,7 @@
from bzrlib.add import smart_add
from bzrlib.builtins import merge
-from bzrlib.errors import IllegalPath
+from bzrlib.errors import IllegalPath, NonAsciiRevisionId
from bzrlib.tests import TestSkipped
from bzrlib.tests.repository_implementations.test_repository import TestCaseWithRepository
from bzrlib.transform import TreeTransform
@@ -223,6 +223,33 @@
self.assertEquals(l1, l2)
+class TestFileIdInvolvedNonAscii(FileIdInvolvedBase):
+
+ def test_utf8_file_ids_and_revision_ids(self):
+ main_wt = self.make_branch_and_tree('main')
+ main_branch = main_wt.branch
+ self.build_tree(["main/a"])
+
+ file_id = u'a-f\xedle-id'
+ main_wt.add(['a'], [file_id])
+ revision_id = u'r\xe9v-a'.encode('utf8')
+ try:
+ main_wt.commit('a', rev_id=revision_id)
+ except NonAsciiRevisionId:
+ raise TestSkipped('non-ascii revision ids not supported by %s'
+ % self.repository_format)
+
+ repo = main_wt.branch.repository
+ file_ids = repo.fileids_altered_by_revision_ids([revision_id])
+ root_id = main_wt.basis_tree().inventory.root.file_id
+ if root_id in file_ids:
+ self.assertEqual({file_id:set([revision_id]),
+ root_id:set([revision_id])
+ }, file_ids)
+ else:
+ self.assertEqual({file_id:set([revision_id])}, file_ids)
+
+
class TestFileIdInvolvedSuperset(FileIdInvolvedBase):
def setUp(self):
=== modified file 'bzrlib/tests/tree_implementations/__init__.py'
--- a/bzrlib/tests/tree_implementations/__init__.py 2007-02-17 17:25:06 +0000
+++ b/bzrlib/tests/tree_implementations/__init__.py 2007-02-17 18:55:58 +0000
@@ -167,6 +167,11 @@
def get_tree_with_utf8(self, tree):
"""Generate a tree with a utf8 revision and unicode paths."""
+ self._create_tree_with_utf8(tree)
+ return self.workingtree_to_test_tree(tree)
+
+ def _create_tree_with_utf8(self, tree):
+ """Generate a tree with a utf8 revision and unicode paths."""
paths = [u'f\xf6',
u'b\xe5r/',
u'b\xe5r/b\xe1z',
@@ -186,6 +191,17 @@
tree.commit(u'in\xedtial', rev_id=u'r\xe9v-1'.encode('utf8'))
except errors.NonAsciiRevisionId:
raise tests.TestSkipped('non-ascii revision ids not supported')
+
+ def get_tree_with_merged_utf8(self, tree):
+ """Generate a tree with utf8 ancestors."""
+ self._create_tree_with_utf8(tree)
+ tree2 = tree.bzrdir.sprout('tree2').open_workingtree()
+ self.build_tree([u'tree2/b\xe5r/z\xf7z'])
+ tree2.add([u'b\xe5r/z\xf7z'], [u'z\xf7z-id'])
+ tree2.commit(u'to m\xe9rge', rev_id=u'r\xe9v-2'.encode('utf8'))
+
+ tree.merge_from_branch(tree2.branch)
+ tree.commit(u'm\xe9rge', rev_id=u'r\xe9v-3'.encode('utf8'))
return self.workingtree_to_test_tree(tree)
=== modified file 'bzrlib/tests/tree_implementations/test_test_trees.py'
--- a/bzrlib/tests/tree_implementations/test_test_trees.py 2007-02-17 17:25:06 +0000
+++ b/bzrlib/tests/tree_implementations/test_test_trees.py 2007-02-17 18:55:58 +0000
@@ -131,3 +131,7 @@
def test_tree_with_utf8(self):
tree = self.make_branch_and_tree('.')
tree = self.get_tree_with_utf8(tree)
+
+ def test_tree_with_merged_utf8(self):
+ tree = self.make_branch_and_tree('.')
+ tree = self.get_tree_with_merged_utf8(tree)
=== modified file 'bzrlib/workingtree.py'
--- a/bzrlib/workingtree.py 2007-02-17 17:25:06 +0000
+++ b/bzrlib/workingtree.py 2007-02-17 18:55:58 +0000
@@ -705,7 +705,7 @@
def _set_merges_from_parent_ids(self, parent_ids):
merges = parent_ids[1:]
- self._control_files.put_utf8('pending-merges', '\n'.join(merges))
+ self._control_files.put_bytes('pending-merges', '\n'.join(merges))
@needs_tree_write_lock
def set_parent_ids(self, revision_ids, allow_leftmost_as_ghost=False):
@@ -2133,7 +2133,7 @@
sio.seek(0)
control_files.put('inventory', sio)
- control_files.put_utf8('pending-merges', '')
+ control_files.put_bytes('pending-merges', '')
def initialize(self, a_bzrdir, revision_id=None):
More information about the bazaar-commits
mailing list