[PATCH 02 of 10] revlog: add a method to tells whether rev is stored as a snapshot

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


# HG changeset patch
# User Paul Morelle <paul.morelle at octobus.net>
# Date 1532086337 -7200
#      Fri Jul 20 13:32:17 2018 +0200
# Node ID ced822e5b2a37bcdaea15366627c035a169a05d3
# Parent  4c025c62ceb8de0f58721f7edd4448b7ef95006d
# EXP-Topic sparse-snapshot
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r ced822e5b2a3
revlog: add a method to tells whether rev is stored as a snapshot

For now we only have one type of snapshot: full snapshot versus nullrev.
However we are looking into adding intermediate snapshot where a large diff
against another snapshot is performed instead of storing a full new text.

The conditional is a bit strange and is done in order to help readability of a
some later changesets.

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -2081,6 +2081,16 @@ class revlog(object):
         else:
             return rev - 1
 
+    def issnapshot(self, rev):
+        """tells whether rev is a snapshot
+        """
+        if rev == nullrev:
+            return True
+        deltap = self.deltaparent(rev)
+        if deltap == nullrev:
+            return True
+        return False
+
     def revdiff(self, rev1, rev2):
         """return or calculate a delta between two revisions
 


More information about the Mercurial-devel mailing list