Patchwork D7848: hashutil: new package for hashing-related features

login
register
mail settings
Submitter phabricator
Date Jan. 13, 2020, 10:48 p.m.
Message ID <differential-rev-PHID-DREV-3kzthd6xbdruv7k6amdk-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/44293/
State Superseded
Headers show

Comments

phabricator - Jan. 13, 2020, 10:48 p.m.
durin42 created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Right now this just tries to use our sha1dc and if it's missing (eg a
  --pure build) we fall back to hashlib. I imagine in the future we'll
  want some other things in here for detecting what hasher is in use as
  we transition off sha1.

REPOSITORY
  rHG Mercurial

BRANCH
  default

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

AFFECTED FILES
  mercurial/utils/hashutil.py

CHANGE DETAILS




To: durin42, #hg-reviewers
Cc: mercurial-devel
phabricator - Jan. 14, 2020, 4:22 a.m.
This revision is now accepted and ready to land.
indygreg added a comment.
indygreg accepted this revision.


  I'm not keen on a new module just for 6 lines. But whatever.

REPOSITORY
  rHG Mercurial

BRANCH
  default

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7848/new/

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

To: durin42, #hg-reviewers, indygreg
Cc: indygreg, mercurial-devel
phabricator - Jan. 14, 2020, 4:18 p.m.
pulkit added a comment.


  Absorbing the following into this patch to make `test-check-module-imports.t` happy.
  
    diff --git a/mercurial/utils/hashutil.py b/mercurial/utils/hashutil.py
    --- a/mercurial/utils/hashutil.py
    +++ b/mercurial/utils/hashutil.py
    @@ -3,7 +3,7 @@ from __future__ import absolute_import
     import hashlib
     
     try:
    -    from mercurial.thirdparty import sha1dc
    +    from ..thirdparty import sha1dc
         sha1 = sha1dc.sha1
     except (ImportError, AttributeError):
         sha1 = hashlib.sha1

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7848/new/

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

To: durin42, #hg-reviewers, indygreg
Cc: pulkit, indygreg, mercurial-devel

Patch

diff --git a/mercurial/utils/hashutil.py b/mercurial/utils/hashutil.py
new file mode 100644
--- /dev/null
+++ b/mercurial/utils/hashutil.py
@@ -0,0 +1,9 @@ 
+from __future__ import absolute_import
+
+import hashlib
+
+try:
+    from mercurial.thirdparty import sha1dc
+    sha1 = sha1dc.sha1
+except (ImportError, AttributeError):
+    sha1 = hashlib.sha1