changeset 40759:0a3cc351d718

perf: fallback to subset if ondisk cache is missing in perfbranchmapload If there is no branchmap on disk for that filter, it means that the cache from some subset's filter is relevant for this one. We look for it instead of aborting. That way it is much simpler to run the command in an automated way. We can now add it to `test-contrib-perf.t`.
author Boris Feld <boris.feld@octobus.net>
date Fri, 23 Nov 2018 02:08:01 +0100
parents 578646b1e2b6
children 0adc2c0a0792
files contrib/perf.py tests/test-contrib-perf.t
diffstat 2 files changed, 14 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/perf.py	Fri Nov 23 02:11:11 2018 +0100
+++ b/contrib/perf.py	Fri Nov 23 02:08:01 2018 +0100
@@ -2247,17 +2247,24 @@
                 ui.status(b'%s - %s\n'
                           % (filtername, util.bytecount(st.st_size)))
         return
-    if filter:
+    if not filter:
+        filter = None
+    subsettable = getbranchmapsubsettable()
+    if filter is None:
+        repo = repo.unfiltered()
+    else:
         repo = repoview.repoview(repo, filter)
-    else:
-        repo = repo.unfiltered()
 
     repo.branchmap() # make sure we have a relevant, up to date branchmap
 
+    currentfilter = filter
     # try once without timer, the filter may not be cached
-    if branchmap.read(repo) is None:
-        raise error.Abort(b'No branchmap cached for %s repo'
-                          % (filter or b'unfiltered'))
+    while branchmap.read(repo) is None:
+        currentfilter = subsettable.get(currentfilter)
+        if currentfilter is None:
+            raise error.Abort(b'No branchmap cached for %s repo'
+                              % (filter or b'unfiltered'))
+        repo = repo.filtered(currentfilter)
     timer, fm = gettimer(ui, opts)
     def setup():
         if clearrevlogs:
--- a/tests/test-contrib-perf.t	Fri Nov 23 02:11:11 2018 +0100
+++ b/tests/test-contrib-perf.t	Fri Nov 23 02:08:01 2018 +0100
@@ -143,6 +143,7 @@
   $ hg perfunidiff --alldata 1
   $ hg perfbookmarks
   $ hg perfbranchmap
+  $ hg perfbranchmapload
   $ hg perfcca
   $ hg perfchangegroupchangelog
   $ hg perfchangegroupchangelog --cgversion 01