Patchwork D5287: py3: use node.hex(m.digest()) instead of m.hexdigest()

login
register
mail settings
Submitter phabricator
Date Nov. 21, 2018, 12:49 p.m.
Message ID <e8e5959b70485ec29588cfa507c6e797@localhost.localdomain>
Download mbox | patch
Permalink /patch/36687/
State Not Applicable
Headers show

Comments

phabricator - Nov. 21, 2018, 12:49 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG9fcf8084ada8: py3: use node.hex(m.digest()) instead of m.hexdigest() (authored by pulkit, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5287?vs=12574&id=12575

REVISION DETAIL
  https://phab.mercurial-scm.org/D5287

AFFECTED FILES
  hgext/fastannotate/context.py
  hgext/largefiles/lfcommands.py
  hgext/lfs/blobstore.py
  hgext/remotefilelog/basepack.py

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: yuja, mercurial-devel

Patch

diff --git a/hgext/remotefilelog/basepack.py b/hgext/remotefilelog/basepack.py
--- a/hgext/remotefilelog/basepack.py
+++ b/hgext/remotefilelog/basepack.py
@@ -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()
 
diff --git a/hgext/lfs/blobstore.py b/hgext/lfs/blobstore.py
--- a/hgext/lfs/blobstore.py
+++ b/hgext/lfs/blobstore.py
@@ -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 --git a/hgext/largefiles/lfcommands.py b/hgext/largefiles/lfcommands.py
--- a/hgext/largefiles/lfcommands.py
+++ b/hgext/largefiles/lfcommands.py
@@ -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 --git a/hgext/fastannotate/context.py b/hgext/fastannotate/context.py
--- a/hgext/fastannotate/context.py
+++ b/hgext/fastannotate/context.py
@@ -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)