Page MenuHomePhabricator

hashutil: new package for hashing-related features
ClosedPublic

Authored by durin42 on Jan 13 2020, 5:48 PM.

Details

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.

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

durin42 created this revision.Jan 13 2020, 5:48 PM
indygreg accepted this revision.Jan 13 2020, 11:22 PM
indygreg added a subscriber: indygreg.

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

This revision is now accepted and ready to land.Jan 13 2020, 11:22 PM
This revision was automatically updated to reflect the committed changes.
pulkit added a subscriber: pulkit.Jan 14 2020, 11:18 AM

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