# HG changeset patch # User Pierre-Yves David # Date 1667757110 18000 # Node ID e706bb41fdb32a9fbc3e9deed73aa0621fa6001a # Parent 2afee2176775e7490e1a07d5ec792b12c6f332c6 delta-find: move pre-filtering with other pre-filtering logic This is more consistent and will help use to be in a clean state before dealing with the "too large group" issue. As a side effect, the debug output now skip some useless cases, making it more useful. diff -r 2afee2176775 -r e706bb41fdb3 mercurial/revlogutils/deltas.py --- a/mercurial/revlogutils/deltas.py Sun Nov 06 13:46:08 2022 -0500 +++ b/mercurial/revlogutils/deltas.py Sun Nov 06 12:51:50 2022 -0500 @@ -661,6 +661,8 @@ p1, p2, cachedelta, + excluded_bases=None, + target_rev=None, ): """Provides group of revision to be tested as delta base @@ -706,6 +708,13 @@ 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: + 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: + continue # filter out delta base that will never produce good delta if deltas_limit < revlog.length(rev): continue @@ -1180,6 +1189,8 @@ p1r, p2r, cachedelta, + excluded_bases, + target_rev, ) candidaterevs = next(groups) while candidaterevs is not None: @@ -1243,16 +1254,7 @@ msg = b"DBG-DELTAS-SEARCH: base=%d\n" msg %= self.revlog.deltaparent(candidaterev) self._write_debug(msg) - if candidaterev in excluded_bases: - if debug_search: - msg = b"DBG-DELTAS-SEARCH: EXCLUDED\n" - self._write_debug(msg) - continue - if candidaterev >= target_rev: - if debug_search: - msg = b"DBG-DELTAS-SEARCH: TOO-HIGH\n" - self._write_debug(msg) - continue + dbg_try_count += 1 if debug_search: diff -r 2afee2176775 -r e706bb41fdb3 tests/test-sparse-revlog.t --- a/tests/test-sparse-revlog.t Sun Nov 06 13:46:08 2022 -0500 +++ b/tests/test-sparse-revlog.t Sun Nov 06 12:51:50 2022 -0500 @@ -159,7 +159,7 @@ 4971 4970 -1 3 5 4930 snap 19179 346472 427596 1.23414 15994877 15567281 36.40652 427596 179288 1.00000 5 $ hg debug-delta-find SPARSE-REVLOG-TEST-FILE 4971 DBG-DELTAS-SEARCH: SEARCH rev=4971 - DBG-DELTAS-SEARCH: ROUND #1 - 2 candidates - search-down + DBG-DELTAS-SEARCH: ROUND #1 - 1 candidates - search-down DBG-DELTAS-SEARCH: CANDIDATE: rev=4962 DBG-DELTAS-SEARCH: type=snapshot-4 DBG-DELTAS-SEARCH: size=18296 @@ -167,11 +167,6 @@ DBG-DELTAS-SEARCH: uncompressed-delta-size=30377 DBG-DELTAS-SEARCH: delta-search-time=* (glob) DBG-DELTAS-SEARCH: DELTA: length=16872 (BAD) - DBG-DELTAS-SEARCH: CANDIDATE: rev=4971 - DBG-DELTAS-SEARCH: type=snapshot-4 - DBG-DELTAS-SEARCH: size=19179 - DBG-DELTAS-SEARCH: base=4930 - DBG-DELTAS-SEARCH: TOO-HIGH DBG-DELTAS-SEARCH: ROUND #2 - 1 candidates - search-down DBG-DELTAS-SEARCH: CANDIDATE: rev=4930 DBG-DELTAS-SEARCH: type=snapshot-3