Skip to content
Snippets Groups Projects
Commit 383e99f6bc99 authored by Pierre-Yves David's avatar Pierre-Yves David :octopus:
Browse files

delta-find: move sparse-revlog delta checks in the associated class

Lets move the specialized code in the specialized class.
parent d7e2acdd50ba
No related branches found
No related tags found
1 merge request!752introduce subclass for delta-search
......@@ -662,8 +662,6 @@
return False
if not self._is_good_delta_info_chain_quality(deltainfo):
return False
if not self._is_good_delta_info_snapshot_constraints(deltainfo):
return False
return True
def _is_good_delta_info_universal(self, deltainfo):
......@@ -746,34 +744,6 @@
return False
return True
def _is_good_delta_info_snapshot_constraints(self, deltainfo):
"""Returns True if the chain associated with snapshots
This performs checks for format that use sparse-revlog and intermediate
snapshots.
This is used by is_good_delta_info.
"""
# if not a snapshot, this method has no filtering to do
if deltainfo.snapshotdepth is None:
return True
# bad delta from intermediate snapshot size limit
#
# If an intermediate snapshot size is higher than the limit. The
# limit exist to prevent endless chain of intermediate delta to be
# created.
if (
self.revinfo.textlen >> deltainfo.snapshotdepth
) < deltainfo.deltalen:
return False
# bad delta if new intermediate snapshot is larger than the previous
# snapshot
if self.revlog.length(deltainfo.base) < deltainfo.deltalen:
return False
return True
@property
def done(self):
"""True when all possible candidate have been tested"""
......@@ -1092,6 +1062,48 @@
class _SparseDeltaSearch(_GeneralDeltaSearch):
"""Delta search variants for sparse-revlog"""
def is_good_delta_info(self, deltainfo):
"""Returns True if the given delta is good.
Good means that it is within the disk span, disk size, and chain length
bounds that we know to be performant.
"""
if not self._is_good_delta_info_universal(deltainfo):
return False
if not self._is_good_delta_info_chain_quality(deltainfo):
return False
if not self._is_good_delta_info_snapshot_constraints(deltainfo):
return False
return True
def _is_good_delta_info_snapshot_constraints(self, deltainfo):
"""Returns True if the chain associated with snapshots
This performs checks for format that use sparse-revlog and intermediate
snapshots.
This is used by is_good_delta_info.
"""
# if not a snapshot, this method has no filtering to do
if deltainfo.snapshotdepth is None:
return True
# bad delta from intermediate snapshot size limit
#
# If an intermediate snapshot size is higher than the limit. The
# limit exist to prevent endless chain of intermediate delta to be
# created.
if (
self.revinfo.textlen >> deltainfo.snapshotdepth
) < deltainfo.deltalen:
return False
# bad delta if new intermediate snapshot is larger than the previous
# snapshot
if self.revlog.length(deltainfo.base) < deltainfo.deltalen:
return False
return True
def _iter_snapshots_base(self):
assert self.revlog.delta_config.sparse_revlog
assert self.current_stage == _STAGE_SNAPSHOT
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment