# HG changeset patch # User Pierre-Yves David # Date 1622391015 -7200 # Node ID 1efe3cdef53aed1680540beab349441b9d4c919f # Parent 9b841267253ca53aa172bffef277a13596c3ccf0 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 diff -r 9b841267253c -r 1efe3cdef53a mercurial/revlogutils/deltas.py --- 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):