##// END OF EJS Templates
hgext: replace references to hashlib.sha1 with hashutil.sha1...
Augie Fackler -
r44519:2d49482d default
parent child Browse files
Show More
@@ -9,7 +9,6 b' from __future__ import absolute_import'
9 9
10 10 import collections
11 11 import contextlib
12 import hashlib
13 12 import os
14 13
15 14 from mercurial.i18n import _
@@ -28,7 +27,10 b' from mercurial import ('
28 27 scmutil,
29 28 util,
30 29 )
31 from mercurial.utils import stringutil
30 from mercurial.utils import (
31 hashutil,
32 stringutil,
33 )
32 34
33 35 from . import (
34 36 error as faerror,
@@ -148,7 +150,7 b' def hashdiffopts(diffopts):'
148 150 diffoptstr = stringutil.pprint(
149 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 156 _defaultdiffopthash = hashdiffopts(mdiff.defaultopts)
@@ -108,7 +108,6 b' created.'
108 108 from __future__ import absolute_import
109 109
110 110 import codecs
111 import hashlib
112 111 import os
113 112 import stat
114 113 import sys
@@ -132,7 +131,10 b' from mercurial import ('
132 131 util,
133 132 )
134 133 from mercurial import match as matchmod
135 from mercurial.utils import stringutil
134 from mercurial.utils import (
135 hashutil,
136 stringutil,
137 )
136 138
137 139 from . import (
138 140 pywatchman,
@@ -235,7 +237,7 b' def _hashignore(ignore):'
235 237 copy.
236 238
237 239 """
238 sha1 = hashlib.sha1()
240 sha1 = hashutil.sha1()
239 241 sha1.update(pycompat.byterepr(ignore))
240 242 return pycompat.sysbytes(sha1.hexdigest())
241 243
@@ -6,7 +6,6 b''
6 6 from __future__ import absolute_import
7 7
8 8 import abc
9 import hashlib
10 9 import os
11 10 import subprocess
12 11 import tempfile
@@ -16,7 +15,10 b' from mercurial import ('
16 15 node,
17 16 pycompat,
18 17 )
19 from mercurial.utils import procutil
18 from mercurial.utils import (
19 hashutil,
20 procutil,
21 )
20 22
21 23 NamedTemporaryFile = tempfile.NamedTemporaryFile
22 24
@@ -87,7 +89,7 b' class filebundlestore(object):'
87 89 return os.path.join(self._dirpath(filename), filename)
88 90
89 91 def write(self, data):
90 filename = node.hex(hashlib.sha1(data).digest())
92 filename = node.hex(hashutil.sha1(data).digest())
91 93 dirpath = self._dirpath(filename)
92 94
93 95 if not os.path.exists(dirpath):
@@ -10,7 +10,6 b''
10 10 from __future__ import absolute_import
11 11
12 12 import errno
13 import hashlib
14 13 import os
15 14 import shutil
16 15
@@ -29,6 +28,7 b' from mercurial import ('
29 28 scmutil,
30 29 util,
31 30 )
31 from mercurial.utils import hashutil
32 32
33 33 from ..convert import (
34 34 convcmd,
@@ -273,7 +273,7 b' def _lfconvert_addchangeset('
273 273 )
274 274
275 275 # largefile was modified, update standins
276 m = hashlib.sha1(b'')
276 m = hashutil.sha1(b'')
277 277 m.update(ctx[f].data())
278 278 hash = node.hex(m.digest())
279 279 if f not in lfiletohash or lfiletohash[f] != hash:
@@ -11,7 +11,6 b' from __future__ import absolute_import'
11 11
12 12 import contextlib
13 13 import copy
14 import hashlib
15 14 import os
16 15 import stat
17 16
@@ -32,6 +31,7 b' from mercurial import ('
32 31 util,
33 32 vfs as vfsmod,
34 33 )
34 from mercurial.utils import hashutil
35 35
36 36 shortname = b'.hglf'
37 37 shortnameslash = shortname + b'/'
@@ -432,7 +432,7 b' def writestandin(repo, standin, hash, ex'
432 432 def copyandhash(instream, outfile):
433 433 '''Read bytes from instream (iterable) and write them to outfile,
434 434 computing the SHA-1 hash of the data along the way. Return the hash.'''
435 hasher = hashlib.sha1(b'')
435 hasher = hashutil.sha1(b'')
436 436 for data in instream:
437 437 hasher.update(data)
438 438 outfile.write(data)
@@ -472,7 +472,7 b' def urljoin(first, second, *arg):'
472 472 def hexsha1(fileobj):
473 473 """hexsha1 returns the hex-encoded sha1 sum of the data in the file-like
474 474 object data"""
475 h = hashlib.sha1()
475 h = hashutil.sha1()
476 476 for chunk in util.filechunkiter(fileobj):
477 477 h.update(chunk)
478 478 return hex(h.digest())
@@ -2,7 +2,6 b' from __future__ import absolute_import'
2 2
3 3 import collections
4 4 import errno
5 import hashlib
6 5 import mmap
7 6 import os
8 7 import struct
@@ -20,6 +19,7 b' from mercurial import ('
20 19 util,
21 20 vfs as vfsmod,
22 21 )
22 from mercurial.utils import hashutil
23 23 from . import shallowutil
24 24
25 25 osutil = policy.importmod('osutil')
@@ -392,7 +392,7 b' class mutablebasepack(versionmixin):'
392 392 )
393 393 self.packfp = os.fdopen(self.packfp, 'wb+')
394 394 self.idxfp = os.fdopen(self.idxfp, 'wb+')
395 self.sha = hashlib.sha1()
395 self.sha = hashutil.sha1()
396 396 self._closed = False
397 397
398 398 # The opener provides no way of doing permission fixup on files created
@@ -1,7 +1,6 b''
1 1 from __future__ import absolute_import
2 2
3 3 import errno
4 import hashlib
5 4 import os
6 5 import shutil
7 6 import stat
@@ -15,6 +14,7 b' from mercurial import ('
15 14 pycompat,
16 15 util,
17 16 )
17 from mercurial.utils import hashutil
18 18 from . import (
19 19 constants,
20 20 shallowutil,
@@ -166,7 +166,7 b' class basestore(object):'
166 166
167 167 # Start with a full manifest, since it'll cover the majority of files
168 168 for filename in self.repo[b'tip'].manifest():
169 sha = hashlib.sha1(filename).digest()
169 sha = hashutil.sha1(filename).digest()
170 170 if sha in missingfilename:
171 171 filenames[filename] = sha
172 172 missingfilename.discard(sha)
@@ -178,7 +178,7 b' class basestore(object):'
178 178 break
179 179 files = cl.readfiles(cl.node(rev))
180 180 for filename in files:
181 sha = hashlib.sha1(filename).digest()
181 sha = hashutil.sha1(filename).digest()
182 182 if sha in missingfilename:
183 183 filenames[filename] = sha
184 184 missingfilename.discard(sha)
@@ -6,7 +6,6 b''
6 6 # GNU General Public License version 2 or any later version.
7 7 from __future__ import absolute_import
8 8
9 import hashlib
10 9 import os
11 10 import zlib
12 11
@@ -21,6 +20,7 b' from mercurial import ('
21 20 pycompat,
22 21 revlog,
23 22 )
23 from mercurial.utils import hashutil
24 24 from . import (
25 25 constants,
26 26 datapack,
@@ -61,7 +61,7 b' def debugremotefilelog(ui, path, **opts)'
61 61
62 62 def buildtemprevlog(repo, file):
63 63 # get filename key
64 filekey = nodemod.hex(hashlib.sha1(file).digest())
64 filekey = nodemod.hex(hashutil.sha1(file).digest())
65 65 filedir = os.path.join(repo.path, b'store/data', filekey)
66 66
67 67 # sort all entries based on linkrev
@@ -421,7 +421,7 b' def dumpdeltachain(ui, deltachain, **opt'
421 421 % (
422 422 hashformatter(node),
423 423 hashformatter(deltabasenode),
424 nodemod.hex(hashlib.sha1(delta).digest()),
424 nodemod.hex(hashutil.sha1(delta).digest()),
425 425 len(delta),
426 426 )
427 427 )
@@ -7,7 +7,6 b''
7 7
8 8 from __future__ import absolute_import
9 9
10 import hashlib
11 10 import io
12 11 import os
13 12 import threading
@@ -25,7 +24,10 b' from mercurial import ('
25 24 util,
26 25 wireprotov1peer,
27 26 )
28 from mercurial.utils import procutil
27 from mercurial.utils import (
28 hashutil,
29 procutil,
30 )
29 31
30 32 from . import (
31 33 constants,
@@ -45,12 +47,12 b' fetchmisses = 0'
45 47
46 48
47 49 def getcachekey(reponame, file, id):
48 pathhash = node.hex(hashlib.sha1(file).digest())
50 pathhash = node.hex(hashutil.sha1(file).digest())
49 51 return os.path.join(reponame, pathhash[:2], pathhash[2:], id)
50 52
51 53
52 54 def getlocalkey(file, id):
53 pathhash = node.hex(hashlib.sha1(file).digest())
55 pathhash = node.hex(hashutil.sha1(file).digest())
54 56 return os.path.join(pathhash, id)
55 57
56 58
@@ -1,6 +1,5 b''
1 1 from __future__ import absolute_import
2 2
3 import hashlib
4 3 import struct
5 4
6 5 from mercurial.node import hex, nullid
@@ -8,6 +7,7 b' from mercurial import ('
8 7 pycompat,
9 8 util,
10 9 )
10 from mercurial.utils import hashutil
11 11 from . import (
12 12 basepack,
13 13 constants,
@@ -197,7 +197,7 b' class historypack(basepack.basepack):'
197 197
198 198 def _findsection(self, name):
199 199 params = self.params
200 namehash = hashlib.sha1(name).digest()
200 namehash = hashutil.sha1(name).digest()
201 201 fanoutkey = struct.unpack(
202 202 params.fanoutstruct, namehash[: params.fanoutprefix]
203 203 )[0]
@@ -499,7 +499,7 b' class mutablehistorypack(basepack.mutabl'
499 499
500 500 # Record metadata for the index
501 501 self.files[filename] = (sectionstart, sectionlen)
502 node = hashlib.sha1(filename).digest()
502 node = hashutil.sha1(filename).digest()
503 503 self.entries[node] = node
504 504
505 505 def close(self, ledger=None):
@@ -517,7 +517,7 b' class mutablehistorypack(basepack.mutabl'
517 517 nodeindexlength = self.NODEINDEXENTRYLENGTH
518 518
519 519 files = (
520 (hashlib.sha1(filename).digest(), filename, offset, size)
520 (hashutil.sha1(filename).digest(), filename, offset, size)
521 521 for filename, (offset, size) in pycompat.iteritems(self.files)
522 522 )
523 523 files = sorted(files)
@@ -8,7 +8,6 b' from __future__ import absolute_import'
8 8
9 9 import collections
10 10 import errno
11 import hashlib
12 11 import os
13 12 import stat
14 13 import struct
@@ -24,6 +23,7 b' from mercurial import ('
24 23 util,
25 24 )
26 25 from mercurial.utils import (
26 hashutil,
27 27 storageutil,
28 28 stringutil,
29 29 )
@@ -39,12 +39,12 b' def isenabled(repo):'
39 39
40 40
41 41 def getcachekey(reponame, file, id):
42 pathhash = node.hex(hashlib.sha1(file).digest())
42 pathhash = node.hex(hashutil.sha1(file).digest())
43 43 return os.path.join(reponame, pathhash[:2], pathhash[2:], id)
44 44
45 45
46 46 def getlocalkey(file, id):
47 pathhash = node.hex(hashlib.sha1(file).digest())
47 pathhash = node.hex(hashutil.sha1(file).digest())
48 48 return os.path.join(pathhash, id)
49 49
50 50
@@ -45,7 +45,6 b' option to ``sqlite`` to enable new repos'
45 45
46 46 from __future__ import absolute_import
47 47
48 import hashlib
49 48 import sqlite3
50 49 import struct
51 50 import threading
@@ -75,7 +74,10 b' from mercurial.interfaces import ('
75 74 repository,
76 75 util as interfaceutil,
77 76 )
78 from mercurial.utils import storageutil
77 from mercurial.utils import (
78 hashutil,
79 storageutil,
80 )
79 81
80 82 try:
81 83 from mercurial import zstd
@@ -807,7 +809,7 b' class sqlitefilestore(object):'
807 809 self._db, pathid, node, {}, {-1: None}, zstddctx=self._dctx
808 810 )
809 811
810 deltahash = hashlib.sha1(fulltext).digest()
812 deltahash = hashutil.sha1(fulltext).digest()
811 813
812 814 if self._compengine == b'zstd':
813 815 deltablob = self._cctx.compress(fulltext)
@@ -837,7 +839,7 b' class sqlitefilestore(object):'
837 839
838 840 # Now create the tombstone delta and replace the delta on the censored
839 841 # node.
840 deltahash = hashlib.sha1(tombstone).digest()
842 deltahash = hashutil.sha1(tombstone).digest()
841 843 tombstonedeltaid = insertdelta(
842 844 self._db, COMPRESSION_NONE, deltahash, tombstone
843 845 )
@@ -1004,7 +1006,7 b' class sqlitefilestore(object):'
1004 1006 # us to de-duplicate. The table is configured to ignore conflicts
1005 1007 # and it is faster to just insert and silently noop than to look
1006 1008 # first.
1007 deltahash = hashlib.sha1(delta).digest()
1009 deltahash = hashutil.sha1(delta).digest()
1008 1010
1009 1011 if self._compengine == b'zstd':
1010 1012 deltablob = self._cctx.compress(delta)
General Comments 0
You need to be logged in to leave comments. Login now