From patchwork Mon Jan 13 22:48:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: D7848: hashutil: new package for hashing-related features From: phabricator X-Patchwork-Id: 44293 Message-Id: To: Phabricator Cc: mercurial-devel@mercurial-scm.org Date: Mon, 13 Jan 2020 22:48:14 +0000 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 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