[PATCH 05 of 10] revlog: add a method to retrieve snapshot depth

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


# HG changeset patch
# User Boris Feld <boris.feld at octobus.net>
# Date 1534327754 -7200
#      Wed Aug 15 12:09:14 2018 +0200
# Node ID 0543f2d7c86af60df21a51b0dc826780400d3a62
# Parent  23af56696ff32b0172570e4430775a7793d9d8f9
# EXP-Topic sparse-snapshot
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 0543f2d7c86a
revlog: add a method to retrieve snapshot depth

Some snapshot property (eg: maximum size) will depend on their depth.

diff --git a/mercurial/revlog.py b/mercurial/revlog.py
--- a/mercurial/revlog.py
+++ b/mercurial/revlog.py
@@ -2094,6 +2094,12 @@ class revlog(object):
             return False
         return self.issnapshot(deltap)
 
+    def snapshotdepth(self, rev):
+        """number of snapshot in the chain before this one"""
+        if not self.issnapshot(rev):
+            raise ProgrammingError('revision %d not a snapshot')
+        return len(self._deltachain(rev)[0]) - 1
+
     def revdiff(self, rev1, rev2):
         """return or calculate a delta between two revisions
 


More information about the Mercurial-devel mailing list