[PATCH 2 of 5] revlog: use hashlib.sha1 directly instead of through util

Augie Fackler raf at durin42.com
Fri Jun 10 00:41:15 EDT 2016


# HG changeset patch
# User Augie Fackler <raf at durin42.com>
# Date 1465531834 14400
#      Fri Jun 10 00:10:34 2016 -0400
# Node ID bd2caf6762219aba40edd4dd697fee70de306940
# Parent  16f5b31b1228212dc175b5a0baf3601cca48330d
revlog: use hashlib.sha1 directly instead of through util

Also remove module-local _sha alias, which was barely used.

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -15,6 +15,7 @@ from __future__ import absolute_import
 
 import collections
 import errno
+import hashlib
 import os
 import struct
 import zlib
@@ -40,7 +41,6 @@ from . import (
 _unpack = struct.unpack
 _compress = zlib.compress
 _decompress = zlib.decompress
-_sha = util.sha1
 
 # revlog header flags
 REVLOGV0 = 0
@@ -74,7 +74,7 @@ def gettype(q):
 def offset_type(offset, type):
     return long(long(offset) << 16 | type)
 
-_nullhash = _sha(nullid)
+_nullhash = hashlib.sha1(nullid)
 
 def hash(text, p1, p2):
     """generate a hash from the given text and its parent hashes
@@ -92,7 +92,7 @@ def hash(text, p1, p2):
         # none of the parent nodes are nullid
         l = [p1, p2]
         l.sort()
-        s = _sha(l[0])
+        s = hashlib.sha1(l[0])
         s.update(l[1])
     s.update(text)
     return s.digest()


More information about the Mercurial-devel mailing list