revlog: add a method to retrieve snapshot depth
Some snapshot property (eg: maximum size) will depend on their depth.
--- 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