diff hgext/remotefilelog/fileserverclient.py @ 44062:2d49482d0dd4

hgext: replace references to hashlib.sha1 with hashutil.sha1 When in a non-pure build of Mercurial, this will provide protections against SHA1 collision attacks. Differential Revision: https://phab.mercurial-scm.org/D7851
author Augie Fackler <augie@google.com>
date Mon, 13 Jan 2020 14:12:31 -0500
parents faf00e30b63f
children 89a2afe31e82
line wrap: on
line diff
--- a/hgext/remotefilelog/fileserverclient.py	Mon Jan 13 17:16:54 2020 -0500
+++ b/hgext/remotefilelog/fileserverclient.py	Mon Jan 13 14:12:31 2020 -0500
@@ -7,7 +7,6 @@
 
 from __future__ import absolute_import
 
-import hashlib
 import io
 import os
 import threading
@@ -25,7 +24,10 @@
     util,
     wireprotov1peer,
 )
-from mercurial.utils import procutil
+from mercurial.utils import (
+    hashutil,
+    procutil,
+)
 
 from . import (
     constants,
@@ -45,12 +47,12 @@
 
 
 def getcachekey(reponame, file, id):
-    pathhash = node.hex(hashlib.sha1(file).digest())
+    pathhash = node.hex(hashutil.sha1(file).digest())
     return os.path.join(reponame, pathhash[:2], pathhash[2:], id)
 
 
 def getlocalkey(file, id):
-    pathhash = node.hex(hashlib.sha1(file).digest())
+    pathhash = node.hex(hashutil.sha1(file).digest())
     return os.path.join(pathhash, id)