Patchwork D7360: perf: make `perfrevlogindex` use the new `index.rev` api if available

login
register
mail settings
Submitter phabricator
Date Nov. 8, 2019, 4:29 p.m.
Message ID <differential-rev-PHID-DREV-peqy2h2havd3bzznhdwz-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/42966/
State Superseded
Headers show

Comments

phabricator - Nov. 8, 2019, 4:29 p.m.
marmoute created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  contrib/perf.py

CHANGE DETAILS




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

Patch

diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -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