From patchwork Mon Nov 4 16:27:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D7211: fsmonitor: normalize Watchman paths to bytes From: phabricator X-Patchwork-Id: 42720 Message-Id: <0f638a5b4eeb8229a17c9c42e2076dbf@localhost.localdomain> To: Phabricator Cc: mercurial-devel@mercurial-scm.org Date: Mon, 4 Nov 2019 16:27:58 +0000 Closed by commit rHG2b8be670dcb6: fsmonitor: normalize Watchman paths to bytes (authored by indygreg). This revision was automatically updated to reflect the committed changes. This revision was not accepted when it landed; it landed in state "Needs Review". REPOSITORY rHG Mercurial CHANGES SINCE LAST UPDATE https://phab.mercurial-scm.org/D7211?vs=17509&id=17527 CHANGES SINCE LAST ACTION https://phab.mercurial-scm.org/D7211/new/ REVISION DETAIL https://phab.mercurial-scm.org/D7211 AFFECTED FILES hgext/fsmonitor/__init__.py CHANGE DETAILS To: indygreg, #hg-reviewers Cc: mercurial-devel 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 @@ # 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: