changeset 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 eb9b8679c852
children 862d23bc5749
files contrib/perf.py tests/test-contrib-perf.t
diffstat 2 files changed, 19 insertions(+), 1 deletions(-) [+]
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()
--- a/tests/test-contrib-perf.t	Mon Aug 27 08:52:33 2018 -0700
+++ b/tests/test-contrib-perf.t	Wed Aug 15 19:45:39 2018 +0000
@@ -166,6 +166,10 @@
   $ hg perflookup 2
   $ hg perflrucache
   $ hg perfmanifest 2
+  $ hg perfmanifest -m 44fe2c8352bb3a478ffd7d8350bbc721920134d1
+  $ hg perfmanifest -m 44fe2c8352bb
+  abort: manifest revision must be integer or full node
+  [255]
   $ hg perfmergecalculate -r 3
   $ hg perfmoonwalk
   $ hg perfnodelookup 2