annotate mercurial/utils/hashutil.py @ 44059:7126d8b8e0e6

hashutil: new package for hashing-related features 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. Differential Revision: https://phab.mercurial-scm.org/D7848
author Augie Fackler <augie@google.com>
date Mon, 13 Jan 2020 17:14:19 -0500
parents
children 521ac0d7047f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
44059
7126d8b8e0e6 hashutil: new package for hashing-related features
Augie Fackler <augie@google.com>
parents:
diff changeset
1 from __future__ import absolute_import
7126d8b8e0e6 hashutil: new package for hashing-related features
Augie Fackler <augie@google.com>
parents:
diff changeset
2
7126d8b8e0e6 hashutil: new package for hashing-related features
Augie Fackler <augie@google.com>
parents:
diff changeset
3 import hashlib
7126d8b8e0e6 hashutil: new package for hashing-related features
Augie Fackler <augie@google.com>
parents:
diff changeset
4
7126d8b8e0e6 hashutil: new package for hashing-related features
Augie Fackler <augie@google.com>
parents:
diff changeset
5 try:
7126d8b8e0e6 hashutil: new package for hashing-related features
Augie Fackler <augie@google.com>
parents:
diff changeset
6 from ..thirdparty import sha1dc
7126d8b8e0e6 hashutil: new package for hashing-related features
Augie Fackler <augie@google.com>
parents:
diff changeset
7
7126d8b8e0e6 hashutil: new package for hashing-related features
Augie Fackler <augie@google.com>
parents:
diff changeset
8 sha1 = sha1dc.sha1
7126d8b8e0e6 hashutil: new package for hashing-related features
Augie Fackler <augie@google.com>
parents:
diff changeset
9 except (ImportError, AttributeError):
7126d8b8e0e6 hashutil: new package for hashing-related features
Augie Fackler <augie@google.com>
parents:
diff changeset
10 sha1 = hashlib.sha1