[PATCH 08 of 10] sparse-revlog: bound number of snapshots in a chain

Boris Feld boris.feld at octobus.net
Thu Aug 16 09:43:15 EDT 2018


# HG changeset patch
# User Paul Morelle <paul.morelle at octobus.net>
# Date 1520422084 -3600
#      Wed Mar 07 12:28:04 2018 +0100
# Node ID 4577a01129c513b870a70f52c071e1e668e94049
# Parent  7417729eb852c6f88530d9659b0a82e3b450fcd4
# EXP-Topic sparse-snapshot
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 4577a01129c5
sparse-revlog: bound number of snapshots in a chain

To limit the number of snapshot chained, we enforce them to be smaller and
smaller. This guarantee the number of snapshot in a chain will be bounded to a
small number.

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -2542,6 +2542,15 @@ class revlog(object):
         if self._maxchainlen and  self._maxchainlen < deltainfo.chainlen:
             return False
 
+        # bad delta from intermediate snapshot size limit
+        #
+        #   If an intermediate snapshot size is higher than the limit.  The
+        #   limit exist to prevent endless chain of intermediate delta to be
+        #   created.
+        if (deltainfo.snapshotdepth is not None and
+                (textlen >> deltainfo.snapshotdepth) < deltainfo.deltalen):
+            return False
+
         return True
 
     def _addrevision(self, node, rawtext, transaction, link, p1, p2, flags,


More information about the Mercurial-devel mailing list