Patchwork [07,of,13] perf: fallback to subset if ondisk cache is missing in perfbranchmapload

login
register
mail settings
Submitter Boris Feld
Date Nov. 23, 2018, 2:09 p.m.
Message ID <e2599c3fba4223ced20a.1542982143@localhost.localdomain>
Download mbox | patch
Permalink /patch/36736/
State Accepted
Headers show

Comments

Boris Feld - Nov. 23, 2018, 2:09 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1542935281 -3600
#      Fri Nov 23 02:08:01 2018 +0100
# Node ID e2599c3fba4223ced20a7a253e67631851cab700
# Parent  9f543638d909768a0db0aa779d37817c4b8878ab
# EXP-Topic perf-branchmap
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r e2599c3fba42
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`.

Patch

diff --git a/contrib/perf.py b/contrib/perf.py
--- a/contrib/perf.py
+++ b/contrib/perf.py
@@ -2199,17 +2199,25 @@  def perfbranchmapload(ui, repo, filter=b
                 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:
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
@@ -140,6 +140,7 @@  perfstatus
   $ hg perfunidiff --alldata 1
   $ hg perfbookmarks
   $ hg perfbranchmap
+  $ hg perfbranchmapload
   $ hg perfcca
   $ hg perfchangegroupchangelog
   $ hg perfchangeset 2