changeset 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
files mercurial/revlog.py
diffstat 1 files changed, 24 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revlog.py	Fri Jul 27 19:09:41 2018 +0200
+++ b/mercurial/revlog.py	Tue Aug 14 13:44:13 2018 -0700
@@ -2473,9 +2473,30 @@
             # certain size. Be also apply this tradeoff here and relax span
             # constraint for small enought content.
             maxdist = self._srmingapsize
-        if (distance > maxdist or deltainfo.deltalen > textlen or
-            deltainfo.compresseddeltalen > textlen * 2 or
-            (self._maxchainlen and deltainfo.chainlen > self._maxchainlen)):
+
+        # Bad delta from read span:
+        #
+        #   If the span of data read is larger than the maximum allowed.
+        if maxdist < distance:
+            return False
+
+        # Bad delta from new delta size:
+        #
+        #   If the delta size is larger than the target text, storing the
+        #   delta will be inefficient.
+        if textlen < deltainfo.deltalen:
+            return False
+
+        # Bad delta from cumulated payload size:
+        #
+        #   If the sum of delta get larger than K * target text length.
+        if textlen * 2  < deltainfo.compresseddeltalen:
+            return False
+
+        # Bad delta from chain length:
+        #
+        #   If the number of delta in the chain gets too high.
+        if self._maxchainlen and  self._maxchainlen < deltainfo.chainlen:
             return False
 
         return True