fsmonitor: make _hashignore compatible with Python 3 stable
authorGregory Szorc <gregory.szorc@gmail.com>
Sat, 02 Nov 2019 13:39:23 -0700
branchstable
changeset 43393 bdebc7b54dca
parent 43392 8a9e53b974ee
child 43394 d359dfc15aca
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
hgext/fsmonitor/__init__.py
--- a/hgext/fsmonitor/__init__.py	Sat Nov 02 13:34:40 2019 -0700
+++ b/hgext/fsmonitor/__init__.py	Sat Nov 02 13:39:23 2019 -0700
@@ -236,8 +236,8 @@
 
     """
     sha1 = hashlib.sha1()
-    sha1.update(repr(ignore))
-    return sha1.hexdigest()
+    sha1.update(pycompat.byterepr(ignore))
+    return pycompat.sysbytes(sha1.hexdigest())
 
 
 _watchmanencoding = pywatchman.encoding.get_local_encoding()