Mercurial > hg
comparison mercurial/revlog.py @ 29339:a9e010cd66e1
revlog: use hashlib.sha1 directly instead of through util
Also remove module-local _sha alias, which was barely used.
author | Augie Fackler <raf@durin42.com> |
---|---|
date | Fri, 10 Jun 2016 00:10:34 -0400 |
parents | e7222d326ea2 |
children | d0ae5b8f80dc |
comparison
equal
deleted
inserted
replaced
29338:81c38cb9c1a1 | 29339:a9e010cd66e1 |
---|---|
13 | 13 |
14 from __future__ import absolute_import | 14 from __future__ import absolute_import |
15 | 15 |
16 import collections | 16 import collections |
17 import errno | 17 import errno |
18 import hashlib | |
18 import os | 19 import os |
19 import struct | 20 import struct |
20 import zlib | 21 import zlib |
21 | 22 |
22 # import stuff from node for others to import from revlog | 23 # import stuff from node for others to import from revlog |
38 | 39 |
39 _pack = struct.pack | 40 _pack = struct.pack |
40 _unpack = struct.unpack | 41 _unpack = struct.unpack |
41 _compress = zlib.compress | 42 _compress = zlib.compress |
42 _decompress = zlib.decompress | 43 _decompress = zlib.decompress |
43 _sha = util.sha1 | |
44 | 44 |
45 # revlog header flags | 45 # revlog header flags |
46 REVLOGV0 = 0 | 46 REVLOGV0 = 0 |
47 REVLOGNG = 1 | 47 REVLOGNG = 1 |
48 REVLOGNGINLINEDATA = (1 << 16) | 48 REVLOGNGINLINEDATA = (1 << 16) |
72 return int(q & 0xFFFF) | 72 return int(q & 0xFFFF) |
73 | 73 |
74 def offset_type(offset, type): | 74 def offset_type(offset, type): |
75 return long(long(offset) << 16 | type) | 75 return long(long(offset) << 16 | type) |
76 | 76 |
77 _nullhash = _sha(nullid) | 77 _nullhash = hashlib.sha1(nullid) |
78 | 78 |
79 def hash(text, p1, p2): | 79 def hash(text, p1, p2): |
80 """generate a hash from the given text and its parent hashes | 80 """generate a hash from the given text and its parent hashes |
81 | 81 |
82 This hash combines both the current file contents and its history | 82 This hash combines both the current file contents and its history |
90 s.update(p1) | 90 s.update(p1) |
91 else: | 91 else: |
92 # none of the parent nodes are nullid | 92 # none of the parent nodes are nullid |
93 l = [p1, p2] | 93 l = [p1, p2] |
94 l.sort() | 94 l.sort() |
95 s = _sha(l[0]) | 95 s = hashlib.sha1(l[0]) |
96 s.update(l[1]) | 96 s.update(l[1]) |
97 s.update(text) | 97 s.update(text) |
98 return s.digest() | 98 return s.digest() |
99 | 99 |
100 def decompress(bin): | 100 def decompress(bin): |