[Request] [+ ] D10887: deltas: at a `target_rev` parameter to finddeltainfo

marmoute (Pierre-Yves David) phabricator at mercurial-scm.org
Sun Jun 20 21:22:40 UTC 2021


marmoute created this revision.
Herald added a reviewer: hg-reviewers.
Herald added a subscriber: mercurial-patches.

REVISION SUMMARY
  Otherwise, recomputing a delta for a revision might result in a delta against a
  later revision or a full snapshot thinking we are appending a new revision.
  
  We will make use of this during censoring (and later, stripping).

REPOSITORY
  rHG Mercurial

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D10887

AFFECTED FILES
  mercurial/revlogutils/deltas.py

CHANGE DETAILS

diff --git a/mercurial/revlogutils/deltas.py b/mercurial/revlogutils/deltas.py
--- a/mercurial/revlogutils/deltas.py
+++ b/mercurial/revlogutils/deltas.py
@@ -1030,8 +1030,7 @@
             snapshotdepth,
         )
 
-    def _fullsnapshotinfo(self, fh, revinfo):
-        curr = len(self.revlog)
+    def _fullsnapshotinfo(self, fh, revinfo, curr):
         rawtext = self.buildtext(revinfo, fh)
         data = self.revlog.compress(rawtext)
         compresseddeltalen = deltalen = dist = len(data[1]) + len(data[0])
@@ -1050,7 +1049,7 @@
             snapshotdepth,
         )
 
-    def finddeltainfo(self, revinfo, fh, excluded_bases=None):
+    def finddeltainfo(self, revinfo, fh, excluded_bases=None, target_rev=None):
         """Find an acceptable delta against a candidate revision
 
         revinfo: information about the revision (instance of _revisioninfo)
@@ -1067,8 +1066,11 @@
         a delta base. Use this to recompute delta suitable in censor or strip
         context.
         """
+        if target_rev is None:
+            curr = len(self.revlog)
+
         if not revinfo.textlen:
-            return self._fullsnapshotinfo(fh, revinfo)
+            return self._fullsnapshotinfo(fh, revinfo, target_rev)
 
         if excluded_bases is None:
             excluded_bases = set()
@@ -1077,7 +1079,7 @@
         # not calling candelta since only one revision needs test, also to
         # avoid overhead fetching flags again.
         if revinfo.flags & REVIDX_RAWTEXT_CHANGING_FLAGS:
-            return self._fullsnapshotinfo(fh, revinfo)
+            return self._fullsnapshotinfo(fh, revinfo, target_rev)
 
         cachedelta = revinfo.cachedelta
         p1 = revinfo.p1
@@ -1099,6 +1101,8 @@
             for candidaterev in candidaterevs:
                 if candidaterev in excluded_bases:
                     continue
+                if candidaterev >= target_rev:
+                    continue
                 candidatedelta = self._builddeltainfo(revinfo, candidaterev, fh)
                 if candidatedelta is not None:
                     if isgooddeltainfo(self.revlog, candidatedelta, revinfo):
@@ -1111,5 +1115,5 @@
                 candidaterevs = next(groups)
 
         if deltainfo is None:
-            deltainfo = self._fullsnapshotinfo(fh, revinfo)
+            deltainfo = self._fullsnapshotinfo(fh, revinfo, target_rev)
         return deltainfo



To: marmoute, #hg-reviewers
Cc: mercurial-patches, mercurial-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mercurial-scm.org/pipermail/mercurial-patches/attachments/20210620/ba9aaccf/attachment-0001.html>


More information about the Mercurial-patches mailing list