diff contrib/perf.py @ 39318:c03c5f528e9b

perf: use storage API for resolving manifest node lookup() isn't part of the storage API. And this code shouldn't be accessing manifestlog._revlog directly for the modern code base. So let's port it to the modern API. Note that the previous code was busted for cases where we needed to call lookup() because lookup() isn't exposed by manifestrevlog any more. This change is strictly BC breaking because we no longer support resolving partial nodes. But it is a perf* command and I don't think we should flag the change as such. Differential Revision: https://phab.mercurial-scm.org/D4390
author Gregory Szorc <gregory.szorc@gmail.com>
date Wed, 15 Aug 2018 19:45:39 +0000
parents c62184c6299c
children 862d23bc5749
line wrap: on
line diff
--- a/contrib/perf.py	Mon Aug 27 08:52:33 2018 -0700
+++ b/contrib/perf.py	Wed Aug 15 19:45:39 2018 +0000
@@ -861,7 +861,21 @@
         ctx = scmutil.revsingle(repo, rev, rev)
         t = ctx.manifestnode()
     else:
-        t = repo.manifestlog._revlog.lookup(rev)
+        from mercurial.node import bin
+
+        if len(rev) == 40:
+            t = bin(rev)
+        else:
+            try:
+                rev = int(rev)
+
+                if util.safehasattr(repo.manifestlog, 'getstorage'):
+                    t = repo.manifestlog.getstorage(b'').node(rev)
+                else:
+                    t = repo.manifestlog._revlog.lookup(rev)
+            except ValueError:
+                raise error.Abort('manifest revision must be integer or full '
+                                  'node')
     def d():
         repo.manifestlog.clearcaches(clear_persisted_data=clear_disk)
         repo.manifestlog[t].read()