revlog: add a ways to blacklist some revision when searching for a delta
This will be useful to recompute appropriate deltas one the fly during
censor/strip operation with revlog-v2.
Differential Revision: https://phab.mercurial-scm.org/D10799
--- a/mercurial/revlogutils/deltas.py Sun May 30 18:08:52 2021 +0200
+++ b/mercurial/revlogutils/deltas.py Sun May 30 18:10:15 2021 +0200
@@ -1050,7 +1050,7 @@
snapshotdepth,
)
- def finddeltainfo(self, revinfo, fh):
+ def finddeltainfo(self, revinfo, fh, excluded_bases=None):
"""Find an acceptable delta against a candidate revision
revinfo: information about the revision (instance of _revisioninfo)
@@ -1062,10 +1062,17 @@
If no suitable deltabase is found, we return delta info for a full
snapshot.
+
+ `excluded_bases` is an optional set of revision that cannot be used as
+ a delta base. Use this to recompute delta suitable in censor or strip
+ context.
"""
if not revinfo.textlen:
return self._fullsnapshotinfo(fh, revinfo)
+ if excluded_bases is None:
+ excluded_bases = set()
+
# no delta for flag processor revision (see "candelta" for why)
# not calling candelta since only one revision needs test, also to
# avoid overhead fetching flags again.
@@ -1090,6 +1097,8 @@
# challenge it against refined candidates
nominateddeltas.append(deltainfo)
for candidaterev in candidaterevs:
+ if candidaterev in excluded_bases:
+ continue
candidatedelta = self._builddeltainfo(revinfo, candidaterev, fh)
if candidatedelta is not None:
if isgooddeltainfo(self.revlog, candidatedelta, revinfo):