changeset 39187:e0da43e2f71f

revlog: compute snapshot depth on delta info We need the information to be available when choosing delta.
author Boris Feld <boris.feld@octobus.net>
date Fri, 20 Jul 2018 14:32:56 +0200
parents 9d6fab487c13
children a43ef77cab1d
files mercurial/revlog.py
diffstat 1 files changed, 15 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revlog.py	Wed Aug 15 12:30:30 2018 +0200
+++ b/mercurial/revlog.py	Fri Jul 20 14:32:56 2018 +0200
@@ -606,6 +606,7 @@
     chainbase = attr.ib()
     chainlen = attr.ib()
     compresseddeltalen = attr.ib()
+    snapshotdepth = attr.ib()
 
 class _deltacomputer(object):
     def __init__(self, revlog):
@@ -736,8 +737,21 @@
         chainlen, compresseddeltalen = revlog._chaininfo(base)
         chainlen += 1
         compresseddeltalen += deltalen
+
+        revlog = self.revlog
+        snapshotdepth = None
+        if deltabase == nullrev:
+            snapshotdepth = 0
+        elif revlog._sparserevlog and revlog.issnapshot(deltabase):
+            # A delta chain should always be one full snapshot,
+            # zero or more semi-snapshots, and zero or more deltas
+            p1, p2 = revlog.rev(revinfo.p1), revlog.rev(revinfo.p2)
+            if deltabase not in (p1, p2) and revlog.issnapshot(deltabase):
+                snapshotdepth = len(revlog._deltachain(deltabase)[0])
+
         return _deltainfo(dist, deltalen, (header, data), deltabase,
-                         chainbase, chainlen, compresseddeltalen)
+                          chainbase, chainlen, compresseddeltalen,
+                          snapshotdepth)
 
     def finddeltainfo(self, revinfo, fh):
         """Find an acceptable delta against a candidate revision