[MERGE] push handles file-ids containing quotes correctly
Aaron Bentley
aaron.bentley at utoronto.ca
Mon Jul 10 22:03:30 BST 2006
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
John Arbash Meinel wrote:
>>>Done, since you insist. I still think it's pointless to test the
>>>unescaper, since if the XML text is not a valid inventory, (even if it's
>>>well-formed XML) file_ids_affected_by is probably broken.
>>>
>>>Aaron
>
>
> Well, it may be valid escaped XML.
Valid escaped XML doesn't make it a valid inventory. Our inventories
are an XML subset that has line breaks after each entry, no comments, no
CDATA, no processing instructions, no numeric entity references...
> We obviously missed ', so it
> seem possible that we are missing others.
Well, yeah. Anything that's not ASCII is going to be serialized as
numeric entity references by ElementTree, because ElementTree defaults
to ASCII, not utf-8. And we don't decode numeric entity references.
> Which we won't find until a
> bug surfaces again. And I'd rather it surface early rather than later.
>
> I don't know of anything we are missing. But I know that as of right
> now, we don't have a lot of testing for extended unicode file ids.
Oh, you know that thing Robert says that "untested code is broken code"?
We can't even commit unicode file-ids.
=== modified file
'bzrlib/tests/interrepository_implementations/test_interrepository.py'
- --- bzrlib/tests/interrepository_implementations/test_interrepository.py
2006-07-10 15:10:57 +0000
+++ bzrlib/tests/interrepository_implementations/test_interrepository.py
2006-07-10 20:50:46 +0000
@@ -182,7 +182,7 @@
def test_fetch_funky_file_id(self):
from_tree = self.make_branch_and_tree('tree')
self.build_tree(['tree/filename'])
- - from_tree.add('filename', 'funky-chars<>%&;"\'')
+ from_tree.add('filename', u'funky-chars<>%&;"\'\u1234')
from_tree.commit('commit filename')
to_repo = self.make_to_repository('to')
to_repo.fetch(from_tree.branch.repository,
from_tree.last_revision())
$ ./bzr selftest funky
...
TestInterRepository.test_fetch_funky_file_id(InterWeaveRepo)]
- ----------------------------------------------------------------------
Traceback (most recent call last):
File
"/home/abentley/bzr/quote-file-ids/bzrlib/tests/interrepository_implementations/test_interrepository.py",
line 186, in test_fetch_funky_file_id
from_tree.commit('commit filename')
File "/home/abentley/bzr/quote-file-ids/bzrlib/decorators.py", line
51, in write_locked
return unbound(self, *args, **kwargs)
File "/home/abentley/bzr/quote-file-ids/bzrlib/workingtree.py", line
528, in commit
committed_id = Commit().commit( working_tree=self, revprops=revprops,
File "/home/abentley/bzr/quote-file-ids/bzrlib/commit.py", line 302,
in commit self._populate_new_inv()
File "/home/abentley/bzr/quote-file-ids/bzrlib/commit.py", line 522,
in _populate_new_inv
path, self.work_tree)
File "/home/abentley/bzr/quote-file-ids/bzrlib/repository.py", line
2096, in record_entry_contents
ie.snapshot(self._new_revision_id, path, previous_entries, tree, self)
File "/home/abentley/bzr/quote-file-ids/bzrlib/inventory.py", line
422, in snapshot
work_tree, commit_builder)
File "/home/abentley/bzr/quote-file-ids/bzrlib/inventory.py", line
437, in _snapshot_into_revision
self._snapshot_text(previous_entries, work_tree, commit_builder)
File "/home/abentley/bzr/quote-file-ids/bzrlib/inventory.py", line
700, in _snapshot_text
self.text_sha1, self.text_size = commit_builder.modified_file_text(
File "/home/abentley/bzr/quote-file-ids/bzrlib/repository.py", line
2135, in modified_file_text
self._add_text_to_weave(file_id, new_lines, file_parents.keys())
File "/home/abentley/bzr/quote-file-ids/bzrlib/repository.py", line
2149, in _add_text_to_weave
versionedfile = self.repository.weave_store.get_weave_or_empty(
File
"/home/abentley/bzr/quote-file-ids/bzrlib/store/versioned/__init__.py",
line 196, in get_weave_or_empty
_filename = self.filename(file_id)
File
"/home/abentley/bzr/quote-file-ids/bzrlib/store/versioned/__init__.py",
line 72, in filename
return self._relpath(file_id)
File "/home/abentley/bzr/quote-file-ids/bzrlib/store/__init__.py",
line 301, in _relpath
prefix = self.hash_prefix(fileid, escaped=True)
File "/home/abentley/bzr/quote-file-ids/bzrlib/store/__init__.py",
line 331, in hash_prefix
return "%02x/" % (adler32(fileid) & 0xff)
UnicodeEncodeError: 'ascii' codec can't encode character u'\u1234' in
position 18: ordinal not in range(128)
- ----------------------------------------------------------------------
Ran 4 tests in 0.364s
FAILED (errors=3)
tests failed
Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFEssCi0F+nu1YWqI0RAiTDAJ97ApPPG5YregjB7MpsDmkAaDLBwACeN3FV
agwFLqHfhh948wYbZA44HnQ=
=G8Lo
-----END PGP SIGNATURE-----
More information about the bazaar
mailing list