mercurial/revlogutils/deltas.py
changeset 51358 383e99f6bc99
parent 51357 d7e2acdd50ba
child 51359 a224ce5694b3
equal deleted inserted replaced
51357:d7e2acdd50ba 51358:383e99f6bc99
   660         """
   660         """
   661         if not self._is_good_delta_info_universal(deltainfo):
   661         if not self._is_good_delta_info_universal(deltainfo):
   662             return False
   662             return False
   663         if not self._is_good_delta_info_chain_quality(deltainfo):
   663         if not self._is_good_delta_info_chain_quality(deltainfo):
   664             return False
   664             return False
   665         if not self._is_good_delta_info_snapshot_constraints(deltainfo):
       
   666             return False
       
   667         return True
   665         return True
   668 
   666 
   669     def _is_good_delta_info_universal(self, deltainfo):
   667     def _is_good_delta_info_universal(self, deltainfo):
   670         """Returns True if the given delta is good.
   668         """Returns True if the given delta is good.
   671 
   669 
   742         if (
   740         if (
   743             self.revlog.delta_config.max_chain_len
   741             self.revlog.delta_config.max_chain_len
   744             and self.revlog.delta_config.max_chain_len < deltainfo.chainlen
   742             and self.revlog.delta_config.max_chain_len < deltainfo.chainlen
   745         ):
   743         ):
   746             return False
   744             return False
   747         return True
       
   748 
       
   749     def _is_good_delta_info_snapshot_constraints(self, deltainfo):
       
   750         """Returns True if the chain associated with snapshots
       
   751 
       
   752         This performs checks for format that use sparse-revlog and intermediate
       
   753         snapshots.
       
   754 
       
   755         This is used by is_good_delta_info.
       
   756         """
       
   757         # if not a snapshot, this method has no filtering to do
       
   758         if deltainfo.snapshotdepth is None:
       
   759             return True
       
   760         # bad delta from intermediate snapshot size limit
       
   761         #
       
   762         #   If an intermediate snapshot size is higher than the limit.  The
       
   763         #   limit exist to prevent endless chain of intermediate delta to be
       
   764         #   created.
       
   765         if (
       
   766             self.revinfo.textlen >> deltainfo.snapshotdepth
       
   767         ) < deltainfo.deltalen:
       
   768             return False
       
   769 
       
   770         # bad delta if new intermediate snapshot is larger than the previous
       
   771         # snapshot
       
   772         if self.revlog.length(deltainfo.base) < deltainfo.deltalen:
       
   773             return False
       
   774 
       
   775         return True
   745         return True
   776 
   746 
   777     @property
   747     @property
   778     def done(self):
   748     def done(self):
   779         """True when all possible candidate have been tested"""
   749         """True when all possible candidate have been tested"""
  1089         yield None
  1059         yield None
  1090 
  1060 
  1091 
  1061 
  1092 class _SparseDeltaSearch(_GeneralDeltaSearch):
  1062 class _SparseDeltaSearch(_GeneralDeltaSearch):
  1093     """Delta search variants for sparse-revlog"""
  1063     """Delta search variants for sparse-revlog"""
       
  1064 
       
  1065     def is_good_delta_info(self, deltainfo):
       
  1066         """Returns True if the given delta is good.
       
  1067 
       
  1068         Good means that it is within the disk span, disk size, and chain length
       
  1069         bounds that we know to be performant.
       
  1070         """
       
  1071         if not self._is_good_delta_info_universal(deltainfo):
       
  1072             return False
       
  1073         if not self._is_good_delta_info_chain_quality(deltainfo):
       
  1074             return False
       
  1075         if not self._is_good_delta_info_snapshot_constraints(deltainfo):
       
  1076             return False
       
  1077         return True
       
  1078 
       
  1079     def _is_good_delta_info_snapshot_constraints(self, deltainfo):
       
  1080         """Returns True if the chain associated with snapshots
       
  1081 
       
  1082         This performs checks for format that use sparse-revlog and intermediate
       
  1083         snapshots.
       
  1084 
       
  1085         This is used by is_good_delta_info.
       
  1086         """
       
  1087         # if not a snapshot, this method has no filtering to do
       
  1088         if deltainfo.snapshotdepth is None:
       
  1089             return True
       
  1090         # bad delta from intermediate snapshot size limit
       
  1091         #
       
  1092         #   If an intermediate snapshot size is higher than the limit.  The
       
  1093         #   limit exist to prevent endless chain of intermediate delta to be
       
  1094         #   created.
       
  1095         if (
       
  1096             self.revinfo.textlen >> deltainfo.snapshotdepth
       
  1097         ) < deltainfo.deltalen:
       
  1098             return False
       
  1099 
       
  1100         # bad delta if new intermediate snapshot is larger than the previous
       
  1101         # snapshot
       
  1102         if self.revlog.length(deltainfo.base) < deltainfo.deltalen:
       
  1103             return False
       
  1104 
       
  1105         return True
  1094 
  1106 
  1095     def _iter_snapshots_base(self):
  1107     def _iter_snapshots_base(self):
  1096         assert self.revlog.delta_config.sparse_revlog
  1108         assert self.revlog.delta_config.sparse_revlog
  1097         assert self.current_stage == _STAGE_SNAPSHOT
  1109         assert self.current_stage == _STAGE_SNAPSHOT
  1098         prev = self.target_rev - 1
  1110         prev = self.target_rev - 1