changeset 49744:4956942c0416

delta-find: adjust the moment when we mark something as "tested" In a coming change, not all elements of `group` might get tested. So we need to have more control about when a revision is actually added to the `tested` set. So we move to a more verbose (and more fragile) version.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sun, 06 Nov 2022 15:03:31 -0500
parents 01ccb45b7393
children da636e7a6d63
files mercurial/revlogutils/deltas.py
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revlogutils/deltas.py	Sun Nov 06 12:53:57 2022 -0500
+++ b/mercurial/revlogutils/deltas.py	Sun Nov 06 15:03:31 2022 -0500
@@ -707,21 +707,25 @@
             # filter out revision we tested already
             if rev in tested:
                 continue
-            tested.add(rev)
             # an higher authority deamed the base unworthy (e.g. censored)
             if excluded_bases is not None and rev in excluded_bases:
+                tested.add(rev)
                 continue
             # We are in some recomputation cases and that rev is too high in
             # the revlog
             if target_rev is not None and rev >= target_rev:
+                tested.add(rev)
                 continue
             # filter out delta base that will never produce good delta
             if deltas_limit < revlog.length(rev):
+                tested.add(rev)
                 continue
             if sparse and revlog.rawsize(rev) < (textlen // LIMIT_BASE2TEXT):
+                tested.add(rev)
                 continue
             # no delta for rawtext-changing revs (see "candelta" for why)
             if revlog.flags(rev) & REVIDX_RAWTEXT_CHANGING_FLAGS:
+                tested.add(rev)
                 continue
 
             # If we reach here, we are about to build and test a delta.
@@ -731,9 +735,11 @@
             chainlen, chainsize = revlog._chaininfo(rev)
             # if chain will be too long, skip base
             if revlog._maxchainlen and chainlen >= revlog._maxchainlen:
+                tested.add(rev)
                 continue
             # if chain already have too much data, skip base
             if deltas_limit < chainsize:
+                tested.add(rev)
                 continue
             if sparse and revlog.upperboundcomp is not None:
                 maxcomp = revlog.upperboundcomp
@@ -752,12 +758,14 @@
                     snapshotlimit = textlen >> snapshotdepth
                     if snapshotlimit < lowestrealisticdeltalen:
                         # delta lower bound is larger than accepted upper bound
+                        tested.add(rev)
                         continue
 
                     # check the relative constraint on the delta size
                     revlength = revlog.length(rev)
                     if revlength < lowestrealisticdeltalen:
                         # delta probable lower bound is larger than target base
+                        tested.add(rev)
                         continue
 
             group.append(rev)
@@ -765,6 +773,7 @@
             # XXX: in the sparse revlog case, group can become large,
             #      impacting performances. Some bounding or slicing mecanism
             #      would help to reduce this impact.
+            tested.update(group)
             good = yield tuple(group)
     yield None