Patchwork [03,of,10] revlog: also detect intermediate snapshots

login
register
mail settings
Submitter Boris Feld
Date Aug. 16, 2018, 1:43 p.m.
Message ID <44f26261d97dddc70ddc.1534426990@FB-lair>
Download mbox | patch
Permalink /patch/33781/
State Accepted
Headers show

Comments

Boris Feld - Aug. 16, 2018, 1:43 p.m.
# HG changeset patch
# User Paul Morelle <paul.morelle@octobus.net>
# Date 1532086488 -7200
#      Fri Jul 20 13:34:48 2018 +0200
# Node ID 44f26261d97dddc70ddcd3a08b0e7597c4179b39
# Parent  ced822e5b2a37bcdaea15366627c035a169a05d3
# EXP-Topic sparse-snapshot
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 44f26261d97d
revlog: also detect intermediate snapshots

Also detect intermediate-snapshot done against another previous snapshot.

Doing an intermediate snapshot instead of a full one can reduce the number of
full snapshots we need. They are especially useful for content with a lot of
churn on the same line (eg: the manifest) where having a delta over multiple
revisions can end up being significantly smaller than the sum of these
revision deltas.

A revlog built using intermediate snapshots can be a bit smaller and reuse
snapshot much more efficiently. This last property is useful combined with
constraints on chain length. Using intermediate snapshot can produce
repository with delta chain ten times shorter without impact on the storage
size.  Shorter chain lengths are faster to restore, greatly improving read
performance.

This changesets (and the following ones) focus on getting the core principle
of intermediate snapshots into Mercurial core. Later changeset will introduce
the strategy to create them.

Patch

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -2089,7 +2089,10 @@  class revlog(object):
         deltap = self.deltaparent(rev)
         if deltap == nullrev:
             return True
-        return False
+        p1, p2 = self.parentrevs(rev)
+        if deltap in (p1, p2):
+            return False
+        return self.issnapshot(deltap)
 
     def revdiff(self, rev1, rev2):
         """return or calculate a delta between two revisions