comparison hgext/largefiles/lfcommands.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 9f70512ae2cf
children a03c177a4679
comparison
equal deleted inserted replaced
44061:cbc5755df6bf 44062:2d49482d0dd4
8 8
9 '''High-level command function for lfconvert, plus the cmdtable.''' 9 '''High-level command function for lfconvert, plus the cmdtable.'''
10 from __future__ import absolute_import 10 from __future__ import absolute_import
11 11
12 import errno 12 import errno
13 import hashlib
14 import os 13 import os
15 import shutil 14 import shutil
16 15
17 from mercurial.i18n import _ 16 from mercurial.i18n import _
18 17
27 node, 26 node,
28 pycompat, 27 pycompat,
29 scmutil, 28 scmutil,
30 util, 29 util,
31 ) 30 )
31 from mercurial.utils import hashutil
32 32
33 from ..convert import ( 33 from ..convert import (
34 convcmd, 34 convcmd,
35 filemap, 35 filemap,
36 ) 36 )
271 raise error.Abort( 271 raise error.Abort(
272 _(b'largefile %s becomes symlink') % f 272 _(b'largefile %s becomes symlink') % f
273 ) 273 )
274 274
275 # largefile was modified, update standins 275 # largefile was modified, update standins
276 m = hashlib.sha1(b'') 276 m = hashutil.sha1(b'')
277 m.update(ctx[f].data()) 277 m.update(ctx[f].data())
278 hash = node.hex(m.digest()) 278 hash = node.hex(m.digest())
279 if f not in lfiletohash or lfiletohash[f] != hash: 279 if f not in lfiletohash or lfiletohash[f] != hash:
280 rdst.wwrite(f, ctx[f].data(), ctx[f].flags()) 280 rdst.wwrite(f, ctx[f].data(), ctx[f].flags())
281 executable = b'x' in ctx[f].flags() 281 executable = b'x' in ctx[f].flags()