remotefilelog: adapt the `debugindex` command to past API changes
authorMatt Harbison <matt_harbison@yahoo.com>
Wed, 21 Aug 2024 17:41:57 -0400
changeset 51821 c371134fef01
parent 51820 71fb6e0a7a35
child 51822 e78b75f3cea9
remotefilelog: adapt the `debugindex` command to past API changes Pytype was missing these problems because it's currently inferring the classes for `filelog` and `revlog` to be `Any`. When that's fixed, these were flagged, so fix these first. The `filelog` class used to subclass `revlog`, but that was changed back in 1541e1a8e87d (with most or all of the "lost" attributes being forwarded to the embedded `revlog` attribute at that time). These forwarded references were dropped over time, and this command has been broken at least as far back as 68282a7b29a7 when the `version` field was dropped. Most of the fixes were as simple as calling the accessor for the embedded `revlog` member, but the general delta feature detection was a bit more involved- I copied the detection for it from `mercurial.revlogutils.debug.debug_revlog()`.
hgext/remotefilelog/debugcommands.py
--- a/hgext/remotefilelog/debugcommands.py	Wed Aug 21 16:13:14 2024 -0400
+++ b/hgext/remotefilelog/debugcommands.py	Wed Aug 21 17:41:57 2024 -0400
@@ -119,7 +119,7 @@
     if format not in (0, 1):
         raise error.Abort(_(b"unknown format %d") % format)
 
-    generaldelta = r.version & revlog.FLAG_GENERALDELTA
+    generaldelta = r.get_revlog()._format_flags & revlog.FLAG_GENERALDELTA
     if generaldelta:
         basehdr = b' delta'
     else:
@@ -144,9 +144,9 @@
     for i in r:
         node = r.node(i)
         if generaldelta:
-            base = r.deltaparent(i)
+            base = r.get_revlog().deltaparent(i)
         else:
-            base = r.chainbase(i)
+            base = r.get_revlog().chainbase(i)
         if format == 0:
             try:
                 pp = r.parents(node)
@@ -156,8 +156,8 @@
                 b"% 6d % 9d % 7d % 6d % 7d %s %s %s\n"
                 % (
                     i,
-                    r.start(i),
-                    r.length(i),
+                    r.get_revlog().start(i),
+                    r.get_revlog().length(i),
                     base,
                     r.linkrev(i),
                     short(node),
@@ -171,10 +171,10 @@
                 b"% 6d %04x % 8d % 8d % 8d % 6d % 6d % 6d % 6d %s\n"
                 % (
                     i,
-                    r.flags(i),
-                    r.start(i),
-                    r.length(i),
-                    r.rawsize(i),
+                    r.get_revlog().flags(i),
+                    r.get_revlog().start(i),
+                    r.get_revlog().length(i),
+                    r.get_revlog().rawsize(i),
                     base,
                     r.linkrev(i),
                     pr[0],