perf: make `perfrevlogindex` use the new `index.rev` api if available
Differential Revision: https://phab.mercurial-scm.org/D7360
--- 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