comparison mercurial/sparse.py @ 44060:a61287a95dc3

core: migrate uses of hashlib.sha1 to hashutil.sha1 Differential Revision: https://phab.mercurial-scm.org/D7849
author Augie Fackler <augie@google.com>
date Mon, 13 Jan 2020 17:15:14 -0500
parents 8ff1ecfadcd1
children b7808443ed6a
comparison
equal deleted inserted replaced
44059:7126d8b8e0e6 44060:a61287a95dc3
5 # This software may be used and distributed according to the terms of the 5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version. 6 # GNU General Public License version 2 or any later version.
7 7
8 from __future__ import absolute_import 8 from __future__ import absolute_import
9 9
10 import hashlib
11 import os 10 import os
12 11
13 from .i18n import _ 12 from .i18n import _
14 from .node import ( 13 from .node import (
15 hex, 14 hex,
22 pathutil, 21 pathutil,
23 pycompat, 22 pycompat,
24 scmutil, 23 scmutil,
25 util, 24 util,
26 ) 25 )
26 from .utils import hashutil
27 27
28 # Whether sparse features are enabled. This variable is intended to be 28 # Whether sparse features are enabled. This variable is intended to be
29 # temporary to facilitate porting sparse to core. It should eventually be 29 # temporary to facilitate porting sparse to core. It should eventually be
30 # a per-repo option, possibly a repo requirement. 30 # a per-repo option, possibly a repo requirement.
31 enabled = False 31 enabled = False
203 tempsignature = cache.get(b'tempsignature') 203 tempsignature = cache.get(b'tempsignature')
204 else: 204 else:
205 tempsignature = b'0' 205 tempsignature = b'0'
206 206
207 if signature is None or (includetemp and tempsignature is None): 207 if signature is None or (includetemp and tempsignature is None):
208 signature = hex(hashlib.sha1(repo.vfs.tryread(b'sparse')).digest()) 208 signature = hex(hashutil.sha1(repo.vfs.tryread(b'sparse')).digest())
209 cache[b'signature'] = signature 209 cache[b'signature'] = signature
210 210
211 if includetemp: 211 if includetemp:
212 raw = repo.vfs.tryread(b'tempsparse') 212 raw = repo.vfs.tryread(b'tempsparse')
213 tempsignature = hex(hashlib.sha1(raw).digest()) 213 tempsignature = hex(hashutil.sha1(raw).digest())
214 cache[b'tempsignature'] = tempsignature 214 cache[b'tempsignature'] = tempsignature
215 215
216 return b'%s %s' % (signature, tempsignature) 216 return b'%s %s' % (signature, tempsignature)
217 217
218 218