# HG changeset patch # User Pierre-Yves David # Date 2019-11-09 12:23:55 # Node ID c314177eb9bb1d59b133f0f9713a6c544af29bca # Parent 22cd0064370dca5c301b45902e0160b1a6a9e317 perf: make `perfrevlogindex` use the new `index.rev` api if available Differential Revision: https://phab.mercurial-scm.org/D7360 diff --git a/contrib/perf.py b/contrib/perf.py --- a/contrib/perf.py +++ b/contrib/perf.py @@ -2599,25 +2599,38 @@ def perfrevlogindex(ui, repo, file_=None 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