changeset 39319:862d23bc5749

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
author Gregory Szorc <gregory.szorc@gmail.com>
date Mon, 27 Aug 2018 08:58:25 -0700
parents c03c5f528e9b
children 57301ba47e66
files contrib/perf.py
diffstat 1 files changed, 14 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- 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.