fsmonitor: normalize Watchman paths to bytes
Otherwise it will be a str on Python 3 and operations below
which operate in the bytes domain will fail.
Differential Revision: https://phab.mercurial-scm.org/D7211
--- a/hgext/fsmonitor/__init__.py Sat Nov 02 14:17:48 2019 -0700
+++ b/hgext/fsmonitor/__init__.py Sat Nov 02 14:26:06 2019 -0700
@@ -407,8 +407,15 @@
# for name case changes.
for entry in result[b'files']:
fname = entry[b'name']
+
+ # Watchman always give us a str. Normalize to bytes on Python 3
+ # using Watchman's encoding, if needed.
+ if not isinstance(fname, bytes):
+ fname = fname.encode(_watchmanencoding)
+
if _fixencoding:
fname = _watchmantofsencoding(fname)
+
if switch_slashes:
fname = fname.replace(b'\\', b'/')
if normalize: