Mercurial > hg
changeset 40675:9fcf8084ada8
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
author | Pulkit Goyal <pulkit@yandex-team.ru> |
---|---|
date | Mon, 19 Nov 2018 21:12:13 +0300 |
parents | 337a38995336 |
children | 1a6bb5a85e30 |
files | hgext/fastannotate/context.py hgext/largefiles/lfcommands.py hgext/lfs/blobstore.py hgext/remotefilelog/basepack.py |
diffstat | 4 files changed, 9 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- 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)
--- 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()
--- 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'))
--- 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()