comparison mercurial/util.py @ 29342:c27dc3c31222

util: drop local aliases for md5, sha1, sha256, and sha512 This used to be needed to paper over hashlib not being in all Pythons we support, but that's not a problem anymore, so we can simplify things a little bit.
author Augie Fackler <raf@durin42.com>
date Fri, 10 Jun 2016 00:13:23 -0400
parents b501579147f1
children 4e6e280e238f
comparison
equal deleted inserted replaced
29341:0d83ad967bf8 29342:c27dc3c31222
62 if os.name == 'nt': 62 if os.name == 'nt':
63 from . import windows as platform 63 from . import windows as platform
64 else: 64 else:
65 from . import posix as platform 65 from . import posix as platform
66 66
67 md5 = hashlib.md5
68 sha1 = hashlib.sha1
69 sha256 = hashlib.sha256
70 sha512 = hashlib.sha512
71 _ = i18n._ 67 _ = i18n._
72 68
73 cachestat = platform.cachestat 69 cachestat = platform.cachestat
74 checkexec = platform.checkexec 70 checkexec = platform.checkexec
75 checklink = platform.checklink 71 checklink = platform.checklink
136 132
137 def safehasattr(thing, attr): 133 def safehasattr(thing, attr):
138 return getattr(thing, attr, _notset) is not _notset 134 return getattr(thing, attr, _notset) is not _notset
139 135
140 DIGESTS = { 136 DIGESTS = {
141 'md5': md5, 137 'md5': hashlib.md5,
142 'sha1': sha1, 138 'sha1': hashlib.sha1,
143 'sha512': sha512, 139 'sha512': hashlib.sha512,
144 } 140 }
145 # List of digest types from strongest to weakest 141 # List of digest types from strongest to weakest
146 DIGESTS_BY_STRENGTH = ['sha512', 'sha1', 'md5'] 142 DIGESTS_BY_STRENGTH = ['sha512', 'sha1', 'md5']
147 143
148 for k in DIGESTS_BY_STRENGTH: 144 for k in DIGESTS_BY_STRENGTH: