# HG changeset patch # User Gregory Szorc # Date 2019-11-02 21:26:06 # Node ID 2b8be670dcb6697617a1f14980debfb926fadfc5 # Parent d359dfc15acaa6fe546f32a5efc8f450cb7af938 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 diff --git a/hgext/fsmonitor/__init__.py b/hgext/fsmonitor/__init__.py --- a/hgext/fsmonitor/__init__.py +++ b/hgext/fsmonitor/__init__.py @@ -407,8 +407,15 @@ def overridewalk(orig, self, match, subr # 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: