[PATCH 5 of 5] util: drop local aliases for md5, sha1, sha256, and sha512
timeless
timeless at gmail.com
Fri Jul 8 16:06:04 UTC 2016
This was bad.
File "/home/timeless/hg/topic/hgext3rd/topic/topicmap.py", line 37,
in _phaseshash
s = util.sha1()
AttributeError: 'module' object has no attribute 'sha1'
File "/home/timeless/hg/evolve-main/hgext/evolve.py", line 3929, in
_obsrelsethashtree
sha = util.sha1()
AttributeError: 'module' object has no attribute 'sha1'
It meant that I ended up w/ a broken hg and thus couldn't easily back
myself out of it.
Can we please leave sha1 in w/ a deprecation warning for at least 1 revision?
Also, the error handling is pretty poor. For this case (AttributeError
/ module missing thing), we should crawl the stack looking for
extensions and suggest disabling them...
On Fri, Jun 10, 2016 at 12:41 AM, Augie Fackler <raf at durin42.com> wrote:
> # HG changeset patch
> # User Augie Fackler <raf at durin42.com>
> # Date 1465532003 14400
> # Fri Jun 10 00:13:23 2016 -0400
> # Node ID fad6ce69483b3b25c6bd9fb2bd9e2e31467f207f
> # Parent c53644cf3126d5fe51a32b464ecf77c3ea2ca549
> 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.
>
> diff --git a/mercurial/util.py b/mercurial/util.py
> --- a/mercurial/util.py
> +++ b/mercurial/util.py
> @@ -64,10 +64,6 @@ if os.name == 'nt':
> else:
> from . import posix as platform
>
> -md5 = hashlib.md5
> -sha1 = hashlib.sha1
> -sha256 = hashlib.sha256
> -sha512 = hashlib.sha512
> _ = i18n._
>
> cachestat = platform.cachestat
> @@ -138,9 +134,9 @@ def safehasattr(thing, attr):
> return getattr(thing, attr, _notset) is not _notset
>
> DIGESTS = {
> - 'md5': md5,
> - 'sha1': sha1,
> - 'sha512': sha512,
> + 'md5': hashlib.md5,
> + 'sha1': hashlib.sha1,
> + 'sha512': hashlib.sha512,
> }
> # List of digest types from strongest to weakest
> DIGESTS_BY_STRENGTH = ['sha512', 'sha1', 'md5']
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
More information about the Mercurial-devel
mailing list