diff contrib/perf.py @ 51493:82c1a388e86a

branchcache: explicitly track inheritence "state" We move from a binary "dirty" flag to a three value "state": "clean", "inherited", "dirty". The "inherited" means that the branch cache is not only "clean", but it is a duplicate of its parent filter. If a branch cache is "inherited", we can non only skip writing its value on disk, but it is a good idea to delete any stale value on disk, as those will just waste time (and possibly induce bug) in the future. We only do this in the update related to transaction or explicit cache update (e.g `hg debugupdatecache`). Deleting the file when we simply detected a stall cache during a read only operation seems more dangerous. We rename `copy` to `inherit_for` to clarify we associate a stronger semantic to the operation.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sun, 10 Mar 2024 05:10:00 +0100
parents 3aba79ce52a9
children ec640dc9cebd
line wrap: on
line diff
--- a/contrib/perf.py	Sun Mar 10 04:53:17 2024 +0100
+++ b/contrib/perf.py	Sun Mar 10 05:10:00 2024 +0100
@@ -4303,8 +4303,16 @@
         baserepo = repo.filtered(b'__perf_branchmap_update_base')
         targetrepo = repo.filtered(b'__perf_branchmap_update_target')
 
+        bcache = repo.branchmap()
+        copy_method = 'copy'
+
         copy_base_kwargs = copy_base_kwargs = {}
-        if 'repo' in getargspec(repo.branchmap().copy).args:
+        if hasattr(bcache, 'copy'):
+            if 'repo' in getargspec(bcache.copy).args:
+                copy_base_kwargs = {"repo": baserepo}
+                copy_target_kwargs = {"repo": targetrepo}
+        else:
+            copy_method = 'inherit_for'
             copy_base_kwargs = {"repo": baserepo}
             copy_target_kwargs = {"repo": targetrepo}
 
@@ -4316,7 +4324,7 @@
             if candidatebm.validfor(baserepo):
                 filtered = repoview.filterrevs(repo, candidatefilter)
                 missing = [r for r in allbaserevs if r in filtered]
-                base = candidatebm.copy(**copy_base_kwargs)
+                base = getattr(candidatebm, copy_method)(**copy_base_kwargs)
                 base.update(baserepo, missing)
                 break
             candidatefilter = subsettable.get(candidatefilter)
@@ -4326,7 +4334,7 @@
             base.update(baserepo, allbaserevs)
 
         def setup():
-            x[0] = base.copy(**copy_target_kwargs)
+            x[0] = getattr(base, copy_method)(**copy_target_kwargs)
             if clearcaches:
                 unfi._revbranchcache = None
                 clearchangelog(repo)