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

delta-find: move pre-filtering of individual revision in its own function

This goes one step further than the previous change by making the pre-filtering
of individual candicates revision in its own function. This will allow subclass
to easily configure this filtering with their own constrains.

The `if True:` part help the readability of this diff a lot and will be drop in
to the next changesets.
parent 02cc19f4f091
No related branches found
No related tags found
1 merge request!752introduce subclass for delta-search
......@@ -726,5 +726,4 @@
"""
deltalength = self.revlog.length
deltaparent = self.revlog.deltaparent
deltas_limit = self.revinfo.textlen * LIMIT_DELTA2TEXT
......@@ -730,5 +729,4 @@
sparse = self.revlog.delta_config.sparse_revlog
tested = self.tested
group = []
for rev in temptative:
......@@ -736,6 +734,15 @@
while not (rev == nullrev or rev in tested or deltalength(rev)):
tested.add(rev)
rev = deltaparent(rev)
if self._pre_filter_rev(rev):
group.append(rev)
else:
self.tested.add(rev)
return group
def _pre_filter_rev(self, rev):
"""return True if it seems okay to test a rev, False otherwise"""
if True:
# no need to try a delta against nullrev, this will be done as
# a last resort.
if rev == nullrev:
......@@ -739,5 +746,5 @@
# no need to try a delta against nullrev, this will be done as
# a last resort.
if rev == nullrev:
continue
return False
# filter out revision we tested already
......@@ -743,6 +750,6 @@
# filter out revision we tested already
if rev in tested:
continue
if rev in self.tested:
return False
# an higher authority deamed the base unworthy (e.g. censored)
if self.excluded_bases is not None and rev in self.excluded_bases:
......@@ -746,8 +753,7 @@
# an higher authority deamed the base unworthy (e.g. censored)
if self.excluded_bases is not None and rev in self.excluded_bases:
tested.add(rev)
continue
return False
# We are in some recomputation cases and that rev is too high
# in the revlog
if self.target_rev is not None and rev >= self.target_rev:
......@@ -751,10 +757,11 @@
# We are in some recomputation cases and that rev is too high
# in the revlog
if self.target_rev is not None and rev >= self.target_rev:
tested.add(rev)
continue
return False
deltas_limit = self.revinfo.textlen * LIMIT_DELTA2TEXT
# filter out delta base that will never produce good delta
#
# if the delta of that base is already bigger than the limit
# for the delta chain size, doing a delta is hopeless.
if deltas_limit < self.revlog.length(rev):
......@@ -756,8 +763,7 @@
# filter out delta base that will never produce good delta
#
# if the delta of that base is already bigger than the limit
# for the delta chain size, doing a delta is hopeless.
if deltas_limit < self.revlog.length(rev):
tested.add(rev)
continue
return False
......@@ -763,6 +769,7 @@
sparse = self.revlog.delta_config.sparse_revlog
# if the revision we test again is too small, the resulting delta
# will be large anyway as that amount of data to be added is big
if sparse and self.revlog.rawsize(rev) < (
self.textlen // LIMIT_BASE2TEXT
):
......@@ -764,10 +771,9 @@
# if the revision we test again is too small, the resulting delta
# will be large anyway as that amount of data to be added is big
if sparse and self.revlog.rawsize(rev) < (
self.textlen // LIMIT_BASE2TEXT
):
tested.add(rev)
continue
return False
# no delta for rawtext-changing revs (see "candelta" for why)
if self.revlog.flags(rev) & REVIDX_RAWTEXT_CHANGING_FLAGS:
......@@ -771,8 +777,7 @@
# no delta for rawtext-changing revs (see "candelta" for why)
if self.revlog.flags(rev) & REVIDX_RAWTEXT_CHANGING_FLAGS:
tested.add(rev)
continue
return False
# If we reach here, we are about to build and test a delta.
# The delta building process will compute the chaininfo in all
......@@ -784,7 +789,6 @@
self.revlog.delta_config.max_chain_len
and chainlen >= self.revlog.delta_config.max_chain_len
):
tested.add(rev)
continue
return False
# if chain already have too much data, skip base
if deltas_limit < chainsize:
......@@ -789,7 +793,6 @@
# if chain already have too much data, skip base
if deltas_limit < chainsize:
tested.add(rev)
continue
return False
if sparse and self.revlog.delta_config.upper_bound_comp is not None:
maxcomp = self.revlog.delta_config.upper_bound_comp
basenotsnap = (self.p1, self.p2, nullrev)
......@@ -808,11 +811,10 @@
if snapshotlimit < lowestrealisticdeltalen:
# delta lower bound is larger than accepted upper
# bound
tested.add(rev)
continue
return False
# check the relative constraint on the delta size
revlength = self.revlog.length(rev)
if revlength < lowestrealisticdeltalen:
# delta probable lower bound is larger than target
# base
......@@ -813,14 +815,11 @@
# check the relative constraint on the delta size
revlength = self.revlog.length(rev)
if revlength < lowestrealisticdeltalen:
# delta probable lower bound is larger than target
# base
tested.add(rev)
continue
group.append(rev)
return group
return False
return True
def _refined_groups(self):
good = None
......
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