Mercurial > hg
comparison hgext/infinitepush/store.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 | 70d42e2ad9b4 |
children | a52bf967e90a |
comparison
equal
deleted
inserted
replaced
44061:cbc5755df6bf | 44062:2d49482d0dd4 |
---|---|
4 # based on bundleheads extension by Gregory Szorc <gps@mozilla.com> | 4 # based on bundleheads extension by Gregory Szorc <gps@mozilla.com> |
5 | 5 |
6 from __future__ import absolute_import | 6 from __future__ import absolute_import |
7 | 7 |
8 import abc | 8 import abc |
9 import hashlib | |
10 import os | 9 import os |
11 import subprocess | 10 import subprocess |
12 import tempfile | 11 import tempfile |
13 | 12 |
14 from mercurial.pycompat import open | 13 from mercurial.pycompat import open |
15 from mercurial import ( | 14 from mercurial import ( |
16 node, | 15 node, |
17 pycompat, | 16 pycompat, |
18 ) | 17 ) |
19 from mercurial.utils import procutil | 18 from mercurial.utils import ( |
19 hashutil, | |
20 procutil, | |
21 ) | |
20 | 22 |
21 NamedTemporaryFile = tempfile.NamedTemporaryFile | 23 NamedTemporaryFile = tempfile.NamedTemporaryFile |
22 | 24 |
23 | 25 |
24 class BundleWriteException(Exception): | 26 class BundleWriteException(Exception): |
85 | 87 |
86 def _filepath(self, filename): | 88 def _filepath(self, filename): |
87 return os.path.join(self._dirpath(filename), filename) | 89 return os.path.join(self._dirpath(filename), filename) |
88 | 90 |
89 def write(self, data): | 91 def write(self, data): |
90 filename = node.hex(hashlib.sha1(data).digest()) | 92 filename = node.hex(hashutil.sha1(data).digest()) |
91 dirpath = self._dirpath(filename) | 93 dirpath = self._dirpath(filename) |
92 | 94 |
93 if not os.path.exists(dirpath): | 95 if not os.path.exists(dirpath): |
94 os.makedirs(dirpath) | 96 os.makedirs(dirpath) |
95 | 97 |