D5152: debugcommands: avoid stack trace from debugindexstats in pure mode

martinvonz (Martin von Zweigbergk) phabricator at mercurial-scm.org
Thu Oct 18 13:48:42 EDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rHG4f37af86d5d5: debugcommands: avoid stack trace from debugindexstats in pure mode (authored by martinvonz, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5152?vs=12248&id=12250

REVISION DETAIL
  https://phab.mercurial-scm.org/D5152

AFFECTED FILES
  mercurial/debugcommands.py
  tests/test-debugcommands.t

CHANGE DETAILS

diff --git a/tests/test-debugcommands.t b/tests/test-debugcommands.t
--- a/tests/test-debugcommands.t
+++ b/tests/test-debugcommands.t
@@ -176,7 +176,12 @@
 
 debugdelta chain basic output
 
-#if reporevlogstore
+#if reporevlogstore pure
+  $ hg debugindexstats
+  abort: debugindexstats only works with native code
+  [255]
+#endif
+#if reporevlogstore no-pure
   $ hg debugindexstats
   node trie capacity: 4
   node trie count: 2
@@ -186,7 +191,9 @@
   node trie misses: 1
   node trie splits: 1
   revs in memory: 3
+#endif
 
+#if reporevlogstore no-pure
   $ hg debugdeltachain -m
       rev  chain# chainlen     prev   delta       size    rawsize  chainsize     ratio   lindist extradist extraratio
         0       1        1       -1    base         44         43         44   1.02326        44         0    0.00000
diff --git a/mercurial/debugcommands.py b/mercurial/debugcommands.py
--- a/mercurial/debugcommands.py
+++ b/mercurial/debugcommands.py
@@ -1168,7 +1168,10 @@
 def debugindexstats(ui, repo):
     """show stats related to the changelog index"""
     repo.changelog.shortest(nullid, 1)
-    for k, v in sorted(repo.changelog.index.stats().items()):
+    index = repo.changelog.index
+    if not util.safehasattr(index, 'stats'):
+        raise error.Abort(_('debugindexstats only works with native code'))
+    for k, v in sorted(index.stats().items()):
         ui.write('%s: %s\n' % (k, v))
 
 @command('debuginstall', [] + cmdutil.formatteropts, '', norepo=True)



To: martinvonz, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list