comparison mercurial/revlogutils/deltas.py @ 51338:176d530f59af

delta-find: move delta size check earlier in is_good_delta_info This will clarify future patches by regrouping related logic before larger movement.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 04 Jan 2024 15:35:36 +0100
parents 1ea56b10dd4a
children 410afe5b13fc
comparison
equal deleted inserted replaced
51337:1ea56b10dd4a 51338:176d530f59af
1055 self.revinfo.cachedelta is None 1055 self.revinfo.cachedelta is None
1056 or self.revinfo.cachedelta[2] != DELTA_BASE_REUSE_FORCE 1056 or self.revinfo.cachedelta[2] != DELTA_BASE_REUSE_FORCE
1057 or not self.revlog.delta_config.general_delta 1057 or not self.revlog.delta_config.general_delta
1058 ) 1058 )
1059 1059
1060 # Bad delta from new delta size:
1061 #
1062 # If the delta size is larger than the target text, storing the delta
1063 # will be inefficient.
1064 if self.revinfo.textlen < deltainfo.deltalen:
1065 return False
1066
1060 # - 'deltainfo.distance' is the distance from the base revision -- 1067 # - 'deltainfo.distance' is the distance from the base revision --
1061 # bounding it limits the amount of I/O we need to do. 1068 # bounding it limits the amount of I/O we need to do.
1062 # - 'deltainfo.compresseddeltalen' is the sum of the total size of 1069 # - 'deltainfo.compresseddeltalen' is the sum of the total size of
1063 # deltas we need to apply -- bounding it limits the amount of CPU 1070 # deltas we need to apply -- bounding it limits the amount of CPU
1064 # we consume. 1071 # we consume.
1081 # practice at all. So we skip the span check entirely. 1088 # practice at all. So we skip the span check entirely.
1082 if ( 1089 if (
1083 not self.revlog.delta_config.sparse_revlog 1090 not self.revlog.delta_config.sparse_revlog
1084 and maxdist < deltainfo.distance 1091 and maxdist < deltainfo.distance
1085 ): 1092 ):
1086 return False
1087
1088 # Bad delta from new delta size:
1089 #
1090 # If the delta size is larger than the target text, storing the delta
1091 # will be inefficient.
1092 if textlen < deltainfo.deltalen:
1093 return False 1093 return False
1094 1094
1095 # Bad delta from cumulated payload size: 1095 # Bad delta from cumulated payload size:
1096 # 1096 #
1097 # If the sum of delta get larger than K * target text length. 1097 # If the sum of delta get larger than K * target text length.