Mercurial > hg
comparison hgext/fastannotate/context.py @ 44062:2d49482d0dd4
hgext: replace references to hashlib.sha1 with hashutil.sha1
When in a non-pure build of Mercurial, this will provide protections
against SHA1 collision attacks.
Differential Revision: https://phab.mercurial-scm.org/D7851
author | Augie Fackler <augie@google.com> |
---|---|
date | Mon, 13 Jan 2020 14:12:31 -0500 |
parents | be384a2052aa |
children | 59fa3890d40a |
comparison
equal
deleted
inserted
replaced
44061:cbc5755df6bf | 44062:2d49482d0dd4 |
---|---|
7 | 7 |
8 from __future__ import absolute_import | 8 from __future__ import absolute_import |
9 | 9 |
10 import collections | 10 import collections |
11 import contextlib | 11 import contextlib |
12 import hashlib | |
13 import os | 12 import os |
14 | 13 |
15 from mercurial.i18n import _ | 14 from mercurial.i18n import _ |
16 from mercurial.pycompat import ( | 15 from mercurial.pycompat import ( |
17 getattr, | 16 getattr, |
26 node, | 25 node, |
27 pycompat, | 26 pycompat, |
28 scmutil, | 27 scmutil, |
29 util, | 28 util, |
30 ) | 29 ) |
31 from mercurial.utils import stringutil | 30 from mercurial.utils import ( |
31 hashutil, | |
32 stringutil, | |
33 ) | |
32 | 34 |
33 from . import ( | 35 from . import ( |
34 error as faerror, | 36 error as faerror, |
35 revmap as revmapmod, | 37 revmap as revmapmod, |
36 ) | 38 ) |
146 | 148 |
147 def hashdiffopts(diffopts): | 149 def hashdiffopts(diffopts): |
148 diffoptstr = stringutil.pprint( | 150 diffoptstr = stringutil.pprint( |
149 sorted((k, getattr(diffopts, k)) for k in mdiff.diffopts.defaults) | 151 sorted((k, getattr(diffopts, k)) for k in mdiff.diffopts.defaults) |
150 ) | 152 ) |
151 return node.hex(hashlib.sha1(diffoptstr).digest())[:6] | 153 return node.hex(hashutil.sha1(diffoptstr).digest())[:6] |
152 | 154 |
153 | 155 |
154 _defaultdiffopthash = hashdiffopts(mdiff.defaultopts) | 156 _defaultdiffopthash = hashdiffopts(mdiff.defaultopts) |
155 | 157 |
156 | 158 |