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

login
register
mail settings
Submitter Boris Feld
Date Aug. 16, 2018, 1:43 p.m.
Message ID <ced822e5b2a37bcdaea1.1534426989@FB-lair>
Download mbox | patch
Permalink /patch/33778/
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 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.

Patch

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