comparison mercurial/branchmap.py @ 47012: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 d4ba4d51f85f
children bea4717415c0
comparison
equal deleted inserted replaced
46992:5fa019ceb499 47012:d55b71393907
10 import struct 10 import struct
11 11
12 from .node import ( 12 from .node import (
13 bin, 13 bin,
14 hex, 14 hex,
15 nullid,
16 nullrev, 15 nullrev,
17 ) 16 )
18 from . import ( 17 from . import (
19 encoding, 18 encoding,
20 error, 19 error,
187 186
188 def __init__( 187 def __init__(
189 self, 188 self,
190 repo, 189 repo,
191 entries=(), 190 entries=(),
192 tipnode=nullid, 191 tipnode=None,
193 tiprev=nullrev, 192 tiprev=nullrev,
194 filteredhash=None, 193 filteredhash=None,
195 closednodes=None, 194 closednodes=None,
196 hasnode=None, 195 hasnode=None,
197 ): 196 ):
198 # type: (localrepo.localrepository, Union[Dict[bytes, List[bytes]], Iterable[Tuple[bytes, List[bytes]]]], bytes, int, Optional[bytes], Optional[Set[bytes]], Optional[Callable[[bytes], bool]]) -> None 197 # type: (localrepo.localrepository, Union[Dict[bytes, List[bytes]], Iterable[Tuple[bytes, List[bytes]]]], bytes, int, Optional[bytes], Optional[Set[bytes]], Optional[Callable[[bytes], bool]]) -> None
199 """hasnode is a function which can be used to verify whether changelog 198 """hasnode is a function which can be used to verify whether changelog
200 has a given node or not. If it's not provided, we assume that every node 199 has a given node or not. If it's not provided, we assume that every node
201 we have exists in changelog""" 200 we have exists in changelog"""
202 self._repo = repo 201 self._repo = repo
203 self.tipnode = tipnode 202 if tipnode is None:
203 self.tipnode = repo.nullid
204 else:
205 self.tipnode = tipnode
204 self.tiprev = tiprev 206 self.tiprev = tiprev
205 self.filteredhash = filteredhash 207 self.filteredhash = filteredhash
206 # closednodes is a set of nodes that close their branch. If the branch 208 # closednodes is a set of nodes that close their branch. If the branch
207 # cache has been updated, it may contain nodes that are no longer 209 # cache has been updated, it may contain nodes that are no longer
208 # heads. 210 # heads.
534 self.tiprev = ntiprev 536 self.tiprev = ntiprev
535 self.tipnode = cl.node(ntiprev) 537 self.tipnode = cl.node(ntiprev)
536 538
537 if not self.validfor(repo): 539 if not self.validfor(repo):
538 # cache key are not valid anymore 540 # cache key are not valid anymore
539 self.tipnode = nullid 541 self.tipnode = repo.nullid
540 self.tiprev = nullrev 542 self.tiprev = nullrev
541 for heads in self.iterheads(): 543 for heads in self.iterheads():
542 tiprev = max(cl.rev(node) for node in heads) 544 tiprev = max(cl.rev(node) for node in heads)
543 if tiprev > self.tiprev: 545 if tiprev > self.tiprev:
544 self.tipnode = cl.node(tiprev) 546 self.tipnode = cl.node(tiprev)