D4390: perf: use storage API for resolving manifest node

indygreg (Gregory Szorc) phabricator at mercurial-scm.org
Mon Aug 27 16:01:13 UTC 2018


indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  contrib/perf.py
  tests/test-contrib-perf.t

CHANGE DETAILS

diff --git a/tests/test-contrib-perf.t b/tests/test-contrib-perf.t
--- a/tests/test-contrib-perf.t
+++ b/tests/test-contrib-perf.t
@@ -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
diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -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()



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


More information about the Mercurial-devel mailing list