Rev 2312: (broken) change safe_*_id to emit a warning. in http://bzr.arbash-meinel.com/branches/bzr/0.15-dev/unicode_id_warnings
John Arbash Meinel
john at arbash-meinel.com
Fri Mar 2 16:19:56 GMT 2007
At http://bzr.arbash-meinel.com/branches/bzr/0.15-dev/unicode_id_warnings
------------------------------------------------------------
revno: 2312
revision-id: john at arbash-meinel.com-20070302161948-63n53irxqf5f72dp
parent: john at arbash-meinel.com-20070302160657-acwr7ptaigpwawle
committer: John Arbash Meinel <john at arbash-meinel.com>
branch nick: unicode_id_warnings
timestamp: Fri 2007-03-02 10:19:48 -0600
message:
(broken) change safe_*_id to emit a warning.
This causes lots of tests to start failing.
modified:
bzrlib/osutils.py osutils.py-20050309040759-eeaff12fbf77ac86
-------------- next part --------------
=== modified file 'bzrlib/osutils.py'
--- a/bzrlib/osutils.py 2007-02-17 21:17:22 +0000
+++ b/bzrlib/osutils.py 2007-03-02 16:19:48 +0000
@@ -54,6 +54,7 @@
""")
import bzrlib
+from bzrlib import symbol_versioning
from bzrlib.symbol_versioning import (
deprecated_function,
zero_nine,
@@ -910,23 +911,28 @@
This is the same as safe_utf8, except it uses the cached encode functions
to save a little bit of performance.
"""
- if unicode_or_utf8_string is None:
- return None
- if isinstance(unicode_or_utf8_string, str):
- # TODO: jam 20070209 Eventually just remove this check.
- try:
- utf8_str = cache_utf8.get_cached_utf8(unicode_or_utf8_string)
- except UnicodeDecodeError:
- raise errors.BzrBadParameterNotUnicode(unicode_or_utf8_string)
- return utf8_str
- return cache_utf8.encode(unicode_or_utf8_string)
-
-
-# TODO: jam 20070217 We start by just re-using safe_revision_id, but ultimately
-# we want to use a different dictionary cache, because trapping file ids
-# and revision ids in the same dict seemed to have a noticable effect on
-# performance.
-safe_file_id = safe_revision_id
+ if (unicode_or_utf8_string is None
+ or unicode_or_utf8_string.__class__ == str):
+ return unicode_or_utf8_string
+ symbol_versioning.warn('Unicode revision ids were deprecated in bzr 0.15.'
+ ' Revision id generators should be creating utf8'
+ ' revision ids.', DeprecationWarning, stacklevel=2)
+ return cache_utf8.encode(unicode_or_utf8_string)
+
+
+def safe_file_id(unicode_or_utf8_string):
+ """File ids should now be utf8, but at one point they were unicode.
+
+ This is the same as safe_utf8, except it uses the cached encode functions
+ to save a little bit of performance.
+ """
+ if (unicode_or_utf8_string is None
+ or unicode_or_utf8_string.__class__ == str):
+ return unicode_or_utf8_string
+ symbol_versioning.warn('Unicode file ids were deprecated in bzr 0.15.'
+ ' File id generators should be creating utf8'
+ ' file ids.', DeprecationWarning, stacklevel=2)
+ return cache_utf8.encode(unicode_or_utf8_string)
_platform_normalizes_filenames = False
More information about the bazaar-commits
mailing list