fsmonitor: coerce `clock` variable to byte-string (issue6321) stable
authorConnor Sheehan <sheehan@mozilla.com>
Tue, 19 May 2020 16:18:41 -0400
branchstable
changeset 44783 017cc5ee537f
parent 44782 50416d3d4b65
child 44784 91e509a12dbc
fsmonitor: coerce `clock` variable to byte-string (issue6321) Callers of `fsmonitor.state.setlastclock` pass their arguments wrapped in `pycompat.sysbytes` to ensure the value is a `bytes` on Python 3. However in `fsmonitor.poststatus.__call__`, if the return value of `getlastclock()` is `None`, we use the value of `fsmonitor.poststatus._startclock` instead, which is not converted to a byte string in the same manner. This commit converts the value of `startclock` to a byte string using `pycompat.sysbytes` in the constructor for `poststatus`, to avoid the "`str` + `bytes`" error from issue 6321. Differential Revision: https://phab.mercurial-scm.org/D8573
hgext/fsmonitor/__init__.py
--- a/hgext/fsmonitor/__init__.py	Thu May 14 23:14:24 2020 -0400
+++ b/hgext/fsmonitor/__init__.py	Tue May 19 16:18:41 2020 -0400
@@ -667,7 +667,7 @@
 
 class poststatus(object):
     def __init__(self, startclock):
-        self._startclock = startclock
+        self._startclock = pycompat.sysbytes(startclock)
 
     def __call__(self, wctx, status):
         clock = wctx.repo()._fsmonitorstate.getlastclock() or self._startclock