debug-revlog-stats: make it use the new store entry API
authorPierre-Yves David <pierre-yves.david@octobus.net>
Fri, 02 Jun 2023 15:12:05 +0200
changeset 50681 47b44d80d836
parent 50680 e324329fc97e
child 50682 2cc5de261d76
debug-revlog-stats: make it use the new store entry API This give use free tree manifest support in the process.
mercurial/revlogutils/debug.py
tests/test-debug-revlog-stats.t
--- a/mercurial/revlogutils/debug.py	Fri Jun 02 15:10:50 2023 +0200
+++ b/mercurial/revlogutils/debug.py	Fri Jun 02 15:12:05 2023 +0200
@@ -663,27 +663,6 @@
     deltacomputer.finddeltainfo(revinfo, fh, target_rev=rev)
 
 
-def _get_revlogs(repo, changelog: bool, manifest: bool, filelogs: bool):
-    """yield revlogs from this repository"""
-    if changelog:
-        yield repo.changelog
-
-    if manifest:
-        # XXX: Handle tree manifest
-        root_mf = repo.manifestlog.getstorage(b'')
-        assert not root_mf._treeondisk
-        yield root_mf._revlog
-
-    if filelogs:
-        files = set()
-        for rev in repo:
-            ctx = repo[rev]
-            files |= set(ctx.files())
-
-        for f in sorted(files):
-            yield repo.file(f)._revlog
-
-
 def debug_revlog_stats(
     repo, fm, changelog: bool, manifest: bool, filelogs: bool
 ):
@@ -693,7 +672,17 @@
     """
     fm.plain(b'rev-count   data-size inl type      target \n')
 
-    for rlog in _get_revlogs(repo, changelog, manifest, filelogs):
+    revlog_entries = [e for e in repo.store.walk() if e.is_revlog]
+    revlog_entries.sort(key=lambda e: (e.revlog_type, e.target_id))
+
+    for entry in revlog_entries:
+        if not changelog and entry.is_changelog:
+            continue
+        elif not manifest and entry.is_manifestlog:
+            continue
+        elif not filelogs and entry.is_filelog:
+            continue
+        rlog = entry.get_revlog_instance(repo).get_revlog()
         fm.startitem()
         nb_rev = len(rlog)
         inline = rlog._inline
--- a/tests/test-debug-revlog-stats.t	Fri Jun 02 15:10:50 2023 +0200
+++ b/tests/test-debug-revlog-stats.t	Fri Jun 02 15:12:05 2023 +0200
@@ -18,8 +18,6 @@
 
   $ hg debug-revlog-stats
   rev-count   data-size inl type      target 
-          0           0 yes changelog 
-          0           0 yes manifest  
 
   $ mkdir folder
   $ touch a b folder/c folder/d