150
_directory_kind: "/",
152
'tree-reference': '+',
147
156
def kind_marker(kind):
150
elif kind == _directory_kind:
152
elif kind == 'symlink':
158
return _kind_marker_map[kind]
155
160
raise errors.BzrError('invalid file kind %r' % kind)
157
163
lexists = getattr(os.path, 'lexists', None)
158
164
if lexists is None:
161
if getattr(os, 'lstat') is not None:
167
stat = getattr(os, 'lstat', os.stat)
167
171
if e.errno == errno.ENOENT:
904
906
return unicode_or_utf8_string.encode('utf-8')
907
def safe_revision_id(unicode_or_utf8_string):
909
_revision_id_warning = ('Unicode revision ids were deprecated in bzr 0.15.'
910
' Revision id generators should be creating utf8'
914
def safe_revision_id(unicode_or_utf8_string, warn=True):
908
915
"""Revision ids should now be utf8, but at one point they were unicode.
917
:param unicode_or_utf8_string: A possibly Unicode revision_id. (can also be
919
:param warn: Functions that are sanitizing user data can set warn=False
920
:return: None or a utf8 revision id.
922
if (unicode_or_utf8_string is None
923
or unicode_or_utf8_string.__class__ == str):
924
return unicode_or_utf8_string
926
symbol_versioning.warn(_revision_id_warning, DeprecationWarning,
928
return cache_utf8.encode(unicode_or_utf8_string)
931
_file_id_warning = ('Unicode file ids were deprecated in bzr 0.15. File id'
932
' generators should be creating utf8 file ids.')
935
def safe_file_id(unicode_or_utf8_string, warn=True):
936
"""File ids should now be utf8, but at one point they were unicode.
910
938
This is the same as safe_utf8, except it uses the cached encode functions
911
939
to save a little bit of performance.
941
:param unicode_or_utf8_string: A possibly Unicode file_id. (can also be
943
:param warn: Functions that are sanitizing user data can set warn=False
944
:return: None or a utf8 file id.
913
if unicode_or_utf8_string is None:
915
if isinstance(unicode_or_utf8_string, str):
916
# TODO: jam 20070209 Eventually just remove this check.
918
utf8_str = cache_utf8.get_cached_utf8(unicode_or_utf8_string)
919
except UnicodeDecodeError:
920
raise errors.BzrBadParameterNotUnicode(unicode_or_utf8_string)
946
if (unicode_or_utf8_string is None
947
or unicode_or_utf8_string.__class__ == str):
948
return unicode_or_utf8_string
950
symbol_versioning.warn(_file_id_warning, DeprecationWarning,
922
952
return cache_utf8.encode(unicode_or_utf8_string)
925
# TODO: jam 20070217 We start by just re-using safe_revision_id, but ultimately
926
# we want to use a different dictionary cache, because trapping file ids
927
# and revision ids in the same dict seemed to have a noticable effect on
929
safe_file_id = safe_revision_id
932
955
_platform_normalizes_filenames = False
933
956
if sys.platform == 'darwin':
934
957
_platform_normalizes_filenames = True