revlog: add a method to retrieve snapshot depth
authorBoris Feld <boris.feld@octobus.net>
Wed, 15 Aug 2018 12:09:14 +0200
changeset 39152 3b1042cab4b4
parent 39151 07b82f55f351
child 39153 9d6fab487c13
revlog: add a method to retrieve snapshot depth Some snapshot property (eg: maximum size) will depend on their depth.
mercurial/revlog.py
--- a/mercurial/revlog.py	Fri Jul 27 10:52:43 2018 +0200
+++ b/mercurial/revlog.py	Wed Aug 15 12:09:14 2018 +0200
@@ -2108,6 +2108,12 @@
             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