perf: add function for obtaining manifest revision
authorGregory Szorc <gregory.szorc@gmail.com>
Mon, 27 Aug 2018 08:58:25 -0700
changeset 39346 862d23bc5749
parent 39345 c03c5f528e9b
child 39347 57301ba47e66
perf: add function for obtaining manifest revision This will use the modern API if available or fall back to the legacy direct revlog access case. Without this, the perf command won't work on all code bases. Differential Revision: https://phab.mercurial-scm.org/D4391
contrib/perf.py
--- a/contrib/perf.py	Wed Aug 15 19:45:39 2018 +0000
+++ b/contrib/perf.py	Mon Aug 27 08:58:25 2018 -0700
@@ -1127,6 +1127,16 @@
         with ready:
             ready.wait()
 
+def _manifestrevision(repo, mnode):
+    ml = repo.manifestlog
+
+    if util.safehasattr(ml, 'getstorage'):
+        store = ml.getstorage(b'')
+    else:
+        store = ml._revlog
+
+    return store.revision(mnode)
+
 @command('perfbdiff', revlogopts + formatteropts + [
     ('', 'count', 1, 'number of revisions to test (when using --startrev)'),
     ('', 'alldata', False, 'test bdiffs for all associated revisions'),
@@ -1172,9 +1182,9 @@
         if opts['alldata']:
             # Load revisions associated with changeset.
             ctx = repo[rev]
-            mtext = repo.manifestlog._revlog.revision(ctx.manifestnode())
+            mtext = _manifestrevision(repo, ctx.manifestnode())
             for pctx in ctx.parents():
-                pman = repo.manifestlog._revlog.revision(pctx.manifestnode())
+                pman = _manifestrevision(repo, pctx.manifestnode())
                 textpairs.append((pman, mtext))
 
             # Load filelog revisions by iterating manifest delta.
@@ -1264,9 +1274,9 @@
         if opts['alldata']:
             # Load revisions associated with changeset.
             ctx = repo[rev]
-            mtext = repo.manifestlog._revlog.revision(ctx.manifestnode())
+            mtext = _manifestrevision(repo, ctx.manifestnode())
             for pctx in ctx.parents():
-                pman = repo.manifestlog._revlog.revision(pctx.manifestnode())
+                pman = _manifestrevision(repo, pctx.manifestnode())
                 textpairs.append((pman, mtext))
 
             # Load filelog revisions by iterating manifest delta.