changeset 43572:c314177eb9bb

perf: make `perfrevlogindex` use the new `index.rev` api if available Differential Revision: https://phab.mercurial-scm.org/D7360
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sat, 09 Nov 2019 13:23:55 +0100
parents 22cd0064370d
children d3df05bab081
files contrib/perf.py
diffstat 1 files changed, 22 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/perf.py	Sat Nov 09 13:23:54 2019 +0100
+++ b/contrib/perf.py	Sat Nov 09 13:23:55 2019 +0100
@@ -2599,25 +2599,38 @@
                 index[rev]
 
     def resolvenode(node):
-        nodemap = getattr(revlogio.parseindex(data, inline)[0], 'nodemap', None)
-        # This only works for the C code.
-        if nodemap is None:
-            return
+        index = revlogio.parseindex(data, inline)[0]
+        rev = getattr(index, 'rev', None)
+        if rev is None:
+            nodemap = getattr(
+                revlogio.parseindex(data, inline)[0], 'nodemap', None
+            )
+            # This only works for the C code.
+            if nodemap is None:
+                return
+            rev = nodemap.__getitem__
 
         try:
-            nodemap[node]
+            rev(node)
         except error.RevlogError:
             pass
 
     def resolvenodes(nodes, count=1):
-        nodemap = getattr(revlogio.parseindex(data, inline)[0], 'nodemap', None)
-        if nodemap is None:
-            return
+        index = revlogio.parseindex(data, inline)[0]
+        rev = getattr(index, 'rev', None)
+        if rev is None:
+            nodemap = getattr(
+                revlogio.parseindex(data, inline)[0], 'nodemap', None
+            )
+            # This only works for the C code.
+            if nodemap is None:
+                return
+            rev = nodemap.__getitem__
 
         for i in range(count):
             for node in nodes:
                 try:
-                    nodemap[node]
+                    rev(node)
                 except error.RevlogError:
                     pass