changeset 39185:3b1042cab4b4

revlog: add a method to retrieve snapshot depth Some snapshot property (eg: maximum size) will depend on their depth.
author Boris Feld <boris.feld@octobus.net>
date Wed, 15 Aug 2018 12:09:14 +0200
parents 07b82f55f351
children 9d6fab487c13
files mercurial/revlog.py
diffstat 1 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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