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