comparison mercurial/utils/storageutil.py @ 47055:d55b71393907

node: replace nullid and friends with nodeconstants class The introduction of 256bit hashes require changes to nullid and other constant magic values. Start pushing them down from repository and revlog where sensible. Differential Revision: https://phab.mercurial-scm.org/D9465
author Joerg Sonnenberger <joerg@bec.de>
date Mon, 29 Mar 2021 01:52:06 +0200
parents 45f0d5297698
children 119790e1c67c
comparison
equal deleted inserted replaced
46992:5fa019ceb499 47055:d55b71393907
11 import struct 11 import struct
12 12
13 from ..i18n import _ 13 from ..i18n import _
14 from ..node import ( 14 from ..node import (
15 bin, 15 bin,
16 nullid,
17 nullrev, 16 nullrev,
17 sha1nodeconstants,
18 ) 18 )
19 from .. import ( 19 from .. import (
20 dagop, 20 dagop,
21 error, 21 error,
22 mdiff, 22 mdiff,
24 ) 24 )
25 from ..interfaces import repository 25 from ..interfaces import repository
26 from ..revlogutils import sidedata as sidedatamod 26 from ..revlogutils import sidedata as sidedatamod
27 from ..utils import hashutil 27 from ..utils import hashutil
28 28
29 _nullhash = hashutil.sha1(nullid) 29 _nullhash = hashutil.sha1(sha1nodeconstants.nullid)
30 30
31 31
32 def hashrevisionsha1(text, p1, p2): 32 def hashrevisionsha1(text, p1, p2):
33 """Compute the SHA-1 for revision data and its parents. 33 """Compute the SHA-1 for revision data and its parents.
34 34
35 This hash combines both the current file contents and its history 35 This hash combines both the current file contents and its history
36 in a manner that makes it easy to distinguish nodes with the same 36 in a manner that makes it easy to distinguish nodes with the same
37 content in the revision graph. 37 content in the revision graph.
38 """ 38 """
39 # As of now, if one of the parent node is null, p2 is null 39 # As of now, if one of the parent node is null, p2 is null
40 if p2 == nullid: 40 if p2 == sha1nodeconstants.nullid:
41 # deep copy of a hash is faster than creating one 41 # deep copy of a hash is faster than creating one
42 s = _nullhash.copy() 42 s = _nullhash.copy()
43 s.update(p1) 43 s.update(p1)
44 else: 44 else:
45 # none of the parent nodes are nullid 45 # none of the parent nodes are nullid
105 """Resolve file revision copy metadata. 105 """Resolve file revision copy metadata.
106 106
107 Returns ``False`` if the file has no copy metadata. Otherwise a 107 Returns ``False`` if the file has no copy metadata. Otherwise a
108 2-tuple of the source filename and node. 108 2-tuple of the source filename and node.
109 """ 109 """
110 if store.parents(node)[0] != nullid: 110 if store.parents(node)[0] != sha1nodeconstants.nullid:
111 return False 111 return False
112 112
113 meta = parsemeta(store.revision(node))[0] 113 meta = parsemeta(store.revision(node))[0]
114 114
115 # copy and copyrev occur in pairs. In rare cases due to old bugs, 115 # copy and copyrev occur in pairs. In rare cases due to old bugs,