##// END OF EJS Templates
branchcache: pass a "verify_node" attribut to __init__ instead of hasnode...
marmoute -
r52345:55158761 default
parent child Browse files
Show More
@@ -216,6 +216,7 b' class branchcache:'
216 216 filteredhash: Optional[bytes] = None,
217 217 closednodes: Optional[Set[bytes]] = None,
218 218 hasnode: Optional[Callable[[bytes], bool]] = None,
219 verify_node: bool = False,
219 220 ) -> None:
220 221 """hasnode is a function which can be used to verify whether changelog
221 222 has a given node or not. If it's not provided, we assume that every node
@@ -236,18 +237,23 b' class branchcache:'
236 237 else:
237 238 self._closednodes = closednodes
238 239 self._entries = dict(entries)
240 # Do we need to verify branch at all ?
241 self._verify_node = verify_node
239 242 # whether closed nodes are verified or not
240 243 self._closedverified = False
241 244 # branches for which nodes are verified
242 245 self._verifiedbranches = set()
243 self._hasnode = hasnode
244 if self._hasnode is None:
245 self._hasnode = lambda x: True
246 self._hasnode = None
247 if self._verify_node:
248 self._hasnode = repo.changelog.hasnode
246 249
247 250 def _verifyclosed(self):
248 251 """verify the closed nodes we have"""
252 if not self._verify_node:
253 return
249 254 if self._closedverified:
250 255 return
256 assert self._hasnode is not None
251 257 for node in self._closednodes:
252 258 if not self._hasnode(node):
253 259 _unknownnode(node)
@@ -256,8 +262,11 b' class branchcache:'
256 262
257 263 def _verifybranch(self, branch):
258 264 """verify head nodes for the given branch."""
265 if not self._verify_node:
266 return
259 267 if branch not in self._entries or branch in self._verifiedbranches:
260 268 return
269 assert self._hasnode is not None
261 270 for n in self._entries[branch]:
262 271 if not self._hasnode(n):
263 272 _unknownnode(n)
@@ -306,7 +315,6 b' class branchcache:'
306 315 last, lrev = cachekey[:2]
307 316 last, lrev = bin(last), int(lrev)
308 317 filteredhash = None
309 hasnode = repo.changelog.hasnode
310 318 if len(cachekey) > 2:
311 319 filteredhash = bin(cachekey[2])
312 320 bcache = cls(
@@ -314,7 +322,7 b' class branchcache:'
314 322 tipnode=last,
315 323 tiprev=lrev,
316 324 filteredhash=filteredhash,
317 hasnode=hasnode,
325 verify_node=True,
318 326 )
319 327 if not bcache.validfor(repo):
320 328 # invalidate the cache
@@ -432,6 +440,7 b' class branchcache:'
432 440 self.tiprev,
433 441 self.filteredhash,
434 442 self._closednodes,
443 verify_node=self._verify_node,
435 444 )
436 445
437 446 def write(self, repo):
General Comments 0
You need to be logged in to leave comments. Login now