##// END OF EJS Templates
fsmonitor: match watchman and filesystem encoding...
Olivier Trempe -
r31846:1064a296 default
parent child Browse files
Show More
@@ -91,14 +91,17 b' will disable itself if any of those are '
91 91
92 92 from __future__ import absolute_import
93 93
94 import codecs
94 95 import hashlib
95 96 import os
96 97 import stat
98 import sys
97 99
98 100 from mercurial.i18n import _
99 101 from mercurial import (
100 102 context,
101 103 encoding,
104 error,
102 105 extensions,
103 106 localrepo,
104 107 merge,
@@ -110,6 +113,7 b' from mercurial import ('
110 113 from mercurial import match as matchmod
111 114
112 115 from . import (
116 pywatchman,
113 117 state,
114 118 watchmanclient,
115 119 )
@@ -159,6 +163,28 b' def _hashignore(ignore):'
159 163 sha1.update('\0')
160 164 return sha1.hexdigest()
161 165
166 _watchmanencoding = pywatchman.encoding.get_local_encoding()
167 _fsencoding = sys.getfilesystemencoding() or sys.getdefaultencoding()
168 _fixencoding = codecs.lookup(_watchmanencoding) != codecs.lookup(_fsencoding)
169
170 def _watchmantofsencoding(path):
171 """Fix path to match watchman and local filesystem encoding
172
173 watchman's paths encoding can differ from filesystem encoding. For example,
174 on Windows, it's always utf-8.
175 """
176 try:
177 decoded = path.decode(_watchmanencoding)
178 except UnicodeDecodeError as e:
179 raise error.Abort(str(e), hint='watchman encoding error')
180
181 try:
182 encoded = decoded.encode(_fsencoding, 'strict')
183 except UnicodeEncodeError as e:
184 raise error.Abort(str(e))
185
186 return encoded
187
162 188 def overridewalk(orig, self, match, subrepos, unknown, ignored, full=True):
163 189 '''Replacement for dirstate.walk, hooking into Watchman.
164 190
@@ -303,6 +329,8 b' def overridewalk(orig, self, match, subr'
303 329 # for name case changes.
304 330 for entry in result['files']:
305 331 fname = entry['name']
332 if _fixencoding:
333 fname = _watchmantofsencoding(fname)
306 334 if switch_slashes:
307 335 fname = fname.replace('\\', '/')
308 336 if normalize:
@@ -26,8 +26,8 b''
26 26 > | sed 's|\\|/|g' | xargs $PYTHON3 contrib/check-py3-compat.py \
27 27 > | sed 's/[0-9][0-9]*)$/*)/'
28 28 hgext/convert/transport.py: error importing: <*Error> No module named 'svn.client' (error at transport.py:*) (glob)
29 hgext/fsmonitor/state.py: error importing: <SyntaxError> from __future__ imports must occur at the beginning of the file (__init__.py, line 30) (error at watchmanclient.py:*)
30 hgext/fsmonitor/watchmanclient.py: error importing: <SyntaxError> from __future__ imports must occur at the beginning of the file (__init__.py, line 30) (error at watchmanclient.py:*)
29 hgext/fsmonitor/state.py: error importing: <SyntaxError> from __future__ imports must occur at the beginning of the file (__init__.py, line 30) (error at __init__.py:*)
30 hgext/fsmonitor/watchmanclient.py: error importing: <SyntaxError> from __future__ imports must occur at the beginning of the file (__init__.py, line 30) (error at __init__.py:*)
31 31 mercurial/cffi/bdiff.py: error importing: <*Error> No module named 'mercurial.cffi' (error at check-py3-compat.py:*) (glob)
32 32 mercurial/cffi/mpatch.py: error importing: <*Error> No module named 'mercurial.cffi' (error at check-py3-compat.py:*) (glob)
33 33 mercurial/cffi/osutil.py: error importing: <*Error> No module named 'mercurial.cffi' (error at check-py3-compat.py:*) (glob)
General Comments 0
You need to be logged in to leave comments. Login now