comparison mercurial/revlog.py @ 39084:152ae0f84f9a

revlog: split and document good delta conditional The logic is still identical, but having each conditional on its own helps to document them and will help to edit them in the future.
author Boris Feld <boris.feld@octobus.net>
date Tue, 14 Aug 2018 13:44:13 -0700
parents 8f83a953dddf
children dbb3e9e44fce
comparison
equal deleted inserted replaced
39083:8f83a953dddf 39084:152ae0f84f9a
2471 if self._sparserevlog and maxdist < self._srmingapsize: 2471 if self._sparserevlog and maxdist < self._srmingapsize:
2472 # In multiple place, we are ignoring irrelevant data range below a 2472 # In multiple place, we are ignoring irrelevant data range below a
2473 # certain size. Be also apply this tradeoff here and relax span 2473 # certain size. Be also apply this tradeoff here and relax span
2474 # constraint for small enought content. 2474 # constraint for small enought content.
2475 maxdist = self._srmingapsize 2475 maxdist = self._srmingapsize
2476 if (distance > maxdist or deltainfo.deltalen > textlen or 2476
2477 deltainfo.compresseddeltalen > textlen * 2 or 2477 # Bad delta from read span:
2478 (self._maxchainlen and deltainfo.chainlen > self._maxchainlen)): 2478 #
2479 # If the span of data read is larger than the maximum allowed.
2480 if maxdist < distance:
2481 return False
2482
2483 # Bad delta from new delta size:
2484 #
2485 # If the delta size is larger than the target text, storing the
2486 # delta will be inefficient.
2487 if textlen < deltainfo.deltalen:
2488 return False
2489
2490 # Bad delta from cumulated payload size:
2491 #
2492 # If the sum of delta get larger than K * target text length.
2493 if textlen * 2 < deltainfo.compresseddeltalen:
2494 return False
2495
2496 # Bad delta from chain length:
2497 #
2498 # If the number of delta in the chain gets too high.
2499 if self._maxchainlen and self._maxchainlen < deltainfo.chainlen:
2479 return False 2500 return False
2480 2501
2481 return True 2502 return True
2482 2503
2483 def _addrevision(self, node, rawtext, transaction, link, p1, p2, flags, 2504 def _addrevision(self, node, rawtext, transaction, link, p1, p2, flags,