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
fsmonitor: handle unicode keys in tuples
In Python 3, keys in the bset tuple are typically str, not
bytes. PyBytes_AsString() would return NULL. But we weren't
checking the return value and this would lead to a segfault.
This commit makes the code type and Python version aware. The
Python version specific code is to allow us to utilize a
modern API for converting str -> char* without having to
allocate an extra PyObject.
FWIW I wanted to assume that keys were always str. However,
there appear to be some bytes keys in some cases. I haven't
debugged this further.
Differential Revision: https://phab.mercurial-scm.org/D7210
fsmonitor: make _hashignore compatible with Python 3
The Hasher wants a bytes but we were feeding it a str. Let's
use our repr() implementation to return bytes.
In addition, the hexdigest() would return a str, which would be
compared against a bytes and would always fail. Normalize to
bytes so the compare works.
Differential Revision: https://phab.mercurial-scm.org/D7209
fsmonitor: normalize hostname to bytes
Without this, we get a str/bytes mismatching when using %
formatting a few lines below.
Differential Revision: https://phab.mercurial-scm.org/D7208
fsmonitor: access repo.root
There is no repo._root. It looks like fsmonitor has
been busted since this access was introduced in
ab1900323b1 in July 2019!
Differential Revision: https://phab.mercurial-scm.org/D7207
fsmonitor: coerce watchman exception to bytes
Without this, we get errors due to passing str to a function
which expects bytes.
Differential Revision: https://phab.mercurial-scm.org/D7206