# HG changeset patch # User Pulkit Goyal # Date 1542651133 -10800 # Node ID 9fcf8084ada80d49fa10f0af38223a948b9d06c1 # Parent 337a389953366f059f2cb88129031ba3e67e0bbc py3: use node.hex(m.digest()) instead of m.hexdigest() hashlib.sha1.hexdigest() returns str on Python 3. Differential Revision: https://phab.mercurial-scm.org/D5287 diff -r 337a38995336 -r 9fcf8084ada8 hgext/fastannotate/context.py --- a/hgext/fastannotate/context.py Sun Nov 18 02:40:47 2018 +0100 +++ b/hgext/fastannotate/context.py Mon Nov 19 21:12:13 2018 +0300 @@ -138,7 +138,7 @@ (k, getattr(diffopts, k)) for k in mdiff.diffopts.defaults )) - return hashlib.sha1(diffoptstr).hexdigest()[:6] + return node.hex(hashlib.sha1(diffoptstr).digest())[:6] _defaultdiffopthash = hashdiffopts(mdiff.defaultopts) diff -r 337a38995336 -r 9fcf8084ada8 hgext/largefiles/lfcommands.py --- a/hgext/largefiles/lfcommands.py Sun Nov 18 02:40:47 2018 +0100 +++ b/hgext/largefiles/lfcommands.py Mon Nov 19 21:12:13 2018 +0300 @@ -240,7 +240,7 @@ # largefile was modified, update standins m = hashlib.sha1('') m.update(ctx[f].data()) - hash = m.hexdigest() + hash = node.hex(m.digest()) if f not in lfiletohash or lfiletohash[f] != hash: rdst.wwrite(f, ctx[f].data(), ctx[f].flags()) executable = 'x' in ctx[f].flags() diff -r 337a38995336 -r 9fcf8084ada8 hgext/lfs/blobstore.py --- a/hgext/lfs/blobstore.py Sun Nov 18 02:40:47 2018 +0100 +++ b/hgext/lfs/blobstore.py Mon Nov 19 21:12:13 2018 +0300 @@ -20,6 +20,7 @@ from mercurial import ( encoding, error, + node, pathutil, pycompat, url as urlmod, @@ -156,7 +157,7 @@ fp.write(chunk) sha256.update(chunk) - realoid = sha256.hexdigest() + realoid = node.hex(sha256.digest()) if realoid != oid: raise LfsCorruptionError(_('corrupt remote lfs object: %s') % oid) @@ -206,7 +207,7 @@ # Don't abort if corruption is detected, because `hg verify` will # give more useful info about the corruption- simply don't add the # hardlink. - if verify or hashlib.sha256(blob).hexdigest() == oid: + if verify or node.hex(hashlib.sha256(blob).digest()) == oid: self.ui.note(_('lfs: found %s in the usercache\n') % oid) lfutil.link(self.cachevfs.join(oid), self.vfs.join(oid)) else: @@ -230,7 +231,7 @@ for chunk in util.filechunkiter(fp, size=1048576): sha256.update(chunk) - return oid == sha256.hexdigest() + return oid == node.hex(sha256.digest()) def has(self, oid): """Returns True if the local blobstore contains the requested blob, @@ -587,7 +588,7 @@ return reduced.values() def _verify(oid, content): - realoid = hashlib.sha256(content).hexdigest() + realoid = node.hex(hashlib.sha256(content).digest()) if realoid != oid: raise LfsCorruptionError(_('detected corrupt lfs object: %s') % oid, hint=_('run hg verify')) diff -r 337a38995336 -r 9fcf8084ada8 hgext/remotefilelog/basepack.py --- a/hgext/remotefilelog/basepack.py Sun Nov 18 02:40:47 2018 +0100 +++ b/hgext/remotefilelog/basepack.py Mon Nov 19 21:12:13 2018 +0300 @@ -10,6 +10,7 @@ from mercurial.i18n import _ from mercurial import ( + node as nodemod, policy, pycompat, util, @@ -412,7 +413,7 @@ return try: - sha = self.sha.hexdigest() + sha = nodemod.hex(self.sha.digest()) self.packfp.close() self.writeindex()