Show More
@@ -91,14 +91,17 b' will disable itself if any of those are ' | |||||
91 |
|
91 | |||
92 | from __future__ import absolute_import |
|
92 | from __future__ import absolute_import | |
93 |
|
93 | |||
|
94 | import codecs | |||
94 | import hashlib |
|
95 | import hashlib | |
95 | import os |
|
96 | import os | |
96 | import stat |
|
97 | import stat | |
|
98 | import sys | |||
97 |
|
99 | |||
98 | from mercurial.i18n import _ |
|
100 | from mercurial.i18n import _ | |
99 | from mercurial import ( |
|
101 | from mercurial import ( | |
100 | context, |
|
102 | context, | |
101 | encoding, |
|
103 | encoding, | |
|
104 | error, | |||
102 | extensions, |
|
105 | extensions, | |
103 | localrepo, |
|
106 | localrepo, | |
104 | merge, |
|
107 | merge, | |
@@ -110,6 +113,7 b' from mercurial import (' | |||||
110 | from mercurial import match as matchmod |
|
113 | from mercurial import match as matchmod | |
111 |
|
114 | |||
112 | from . import ( |
|
115 | from . import ( | |
|
116 | pywatchman, | |||
113 | state, |
|
117 | state, | |
114 | watchmanclient, |
|
118 | watchmanclient, | |
115 | ) |
|
119 | ) | |
@@ -159,6 +163,28 b' def _hashignore(ignore):' | |||||
159 | sha1.update('\0') |
|
163 | sha1.update('\0') | |
160 | return sha1.hexdigest() |
|
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 | def overridewalk(orig, self, match, subrepos, unknown, ignored, full=True): |
|
188 | def overridewalk(orig, self, match, subrepos, unknown, ignored, full=True): | |
163 | '''Replacement for dirstate.walk, hooking into Watchman. |
|
189 | '''Replacement for dirstate.walk, hooking into Watchman. | |
164 |
|
190 | |||
@@ -303,6 +329,8 b' def overridewalk(orig, self, match, subr' | |||||
303 | # for name case changes. |
|
329 | # for name case changes. | |
304 | for entry in result['files']: |
|
330 | for entry in result['files']: | |
305 | fname = entry['name'] |
|
331 | fname = entry['name'] | |
|
332 | if _fixencoding: | |||
|
333 | fname = _watchmantofsencoding(fname) | |||
306 | if switch_slashes: |
|
334 | if switch_slashes: | |
307 | fname = fname.replace('\\', '/') |
|
335 | fname = fname.replace('\\', '/') | |
308 | if normalize: |
|
336 | if normalize: |
@@ -26,8 +26,8 b'' | |||||
26 | > | sed 's|\\|/|g' | xargs $PYTHON3 contrib/check-py3-compat.py \ |
|
26 | > | sed 's|\\|/|g' | xargs $PYTHON3 contrib/check-py3-compat.py \ | |
27 | > | sed 's/[0-9][0-9]*)$/*)/' |
|
27 | > | sed 's/[0-9][0-9]*)$/*)/' | |
28 | hgext/convert/transport.py: error importing: <*Error> No module named 'svn.client' (error at transport.py:*) (glob) |
|
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 |
|
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 |
|
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 | mercurial/cffi/bdiff.py: error importing: <*Error> No module named 'mercurial.cffi' (error at check-py3-compat.py:*) (glob) |
|
31 | mercurial/cffi/bdiff.py: error importing: <*Error> No module named 'mercurial.cffi' (error at check-py3-compat.py:*) (glob) | |
32 | mercurial/cffi/mpatch.py: error importing: <*Error> No module named 'mercurial.cffi' (error at check-py3-compat.py:*) (glob) |
|
32 | mercurial/cffi/mpatch.py: error importing: <*Error> No module named 'mercurial.cffi' (error at check-py3-compat.py:*) (glob) | |
33 | mercurial/cffi/osutil.py: error importing: <*Error> No module named 'mercurial.cffi' (error at check-py3-compat.py:*) (glob) |
|
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