[PATCH 07 of 10] sparse-revlog: compute snapshot depth on delta info
Boris Feld
boris.feld at octobus.net
Thu Aug 16 09:43:14 EDT 2018
# HG changeset patch
# User Boris Feld <boris.feld at octobus.net>
# Date 1532089976 -7200
# Fri Jul 20 14:32:56 2018 +0200
# Node ID 7417729eb852c6f88530d9659b0a82e3b450fcd4
# Parent e78ae4e123a35629a1fd25bf264c7be812e1c8e3
# EXP-Topic sparse-snapshot
# Available At https://bitbucket.org/octobus/mercurial-devel/
# hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 7417729eb852
sparse-revlog: compute snapshot depth on delta info
We need the information to be available when choosing delta.
diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -595,6 +595,7 @@ class _deltainfo(object):
chainbase = attr.ib()
chainlen = attr.ib()
compresseddeltalen = attr.ib()
+ snapshotdepth = attr.ib()
class _deltacomputer(object):
def __init__(self, revlog):
@@ -725,8 +726,21 @@ class _deltacomputer(object):
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
More information about the Mercurial-devel
mailing list