Patchwork [08,of,10] deltas: skip if projected compressed size does not match text size constraint

login
register
mail settings
Submitter Pierre-Yves David
Date June 13, 2019, 1:23 p.m.
Message ID <f724b0c7cef6c2069c03.1560432183@nodosa.octopoid.net>
Download mbox | patch
Permalink /patch/40480/
State Accepted
Headers show

Comments

Patch

diff --git a/mercurial/revlogutils/deltas.py b/mercurial/revlogutils/deltas.py
--- a/mercurial/revlogutils/deltas.py
+++ b/mercurial/revlogutils/deltas.py
@@ -960,6 +960,12 @@  class deltacomputer(object):
                 delta = revinfo.cachedelta[1]
         if delta is None:
             delta = self._builddeltadiff(base, revinfo, fh)
+        # snapshotdept need to be neither None nor 0 level snapshot
+        if revlog.upperboundcomp is not None and snapshotdepth:
+            lowestrealisticdeltalen = len(delta) // revlog.upperboundcomp
+            snapshotlimit = revinfo.textlen >> snapshotdepth
+            if snapshotlimit < lowestrealisticdeltalen:
+                return None
         header, data = revlog.compress(delta)
         deltalen = len(header) + len(data)
         offset = revlog.end(len(revlog) - 1)