comparison hgext/absorb.py @ 46780:6266d19556ad

node: introduce nodeconstants class In preparing for moving from SHA1 hashes to a modern hash function, place nullid and other constant magic vules in a class. Provide the active set of constants in the repository and push it down. Provide nullid directly in strategic places like the repository as it is accessed very often. This changeset introduces the API change, but not the mechanical replacement of the node.py attributes itself. Differential Revision: https://phab.mercurial-scm.org/D9750
author Joerg Sonnenberger <joerg@bec.de>
date Wed, 13 Jan 2021 16:14:58 +0100
parents 59fa3890d40a
children d55b71393907
comparison
equal deleted inserted replaced
46779:49fd21f32695 46780:6266d19556ad
100 100
101 101
102 class emptyfilecontext(object): 102 class emptyfilecontext(object):
103 """minimal filecontext representing an empty file""" 103 """minimal filecontext representing an empty file"""
104 104
105 def __init__(self, repo):
106 self._repo = repo
107
105 def data(self): 108 def data(self):
106 return b'' 109 return b''
107 110
108 def node(self): 111 def node(self):
109 return nullid 112 return nullid
210 213
211 if pctx is not None: # need an extra immutable fctx 214 if pctx is not None: # need an extra immutable fctx
212 if path in pctx: 215 if path in pctx:
213 fctxs.append(pctx[path]) 216 fctxs.append(pctx[path])
214 else: 217 else:
215 fctxs.append(emptyfilecontext()) 218 fctxs.append(emptyfilecontext(pctx.repo()))
216 219
217 fctxs.reverse() 220 fctxs.reverse()
218 # note: we rely on a property of hg: filerev is not reused for linear 221 # note: we rely on a property of hg: filerev is not reused for linear
219 # history. i.e. it's impossible to have: 222 # history. i.e. it's impossible to have:
220 # changelog: 4----5----6 (linear, no merges) 223 # changelog: 4----5----6 (linear, no merges)