Mercurial > public > mercurial-scm > hg-stable
diff contrib/perf.py @ 51515:3aba79ce52a9
branchcache: pass the target repository when copying
Branchmap are usually copied to be used on a different repoview using a
different filter level. Passing the repository around means the repository in
`branchcache._repo` will drift from the actual branchmap filter.
This is currently "fine" because the repo is only used to retrieve the `nullid`
value. However, this is a fairly big trap for any extension or future code using
the `_repo` attribute.
The replace logic is now using a copy to ensure the right repository view is
used to initialized the cached value.
We add a couple of assert for make sure this inconsistency does not sneak back.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Mon, 19 Feb 2024 11:43:19 +0100 |
parents | d1fb42a71676 |
children | 82c1a388e86a |
line wrap: on
line diff
--- a/contrib/perf.py Fri Jan 19 11:30:10 2024 +0100 +++ b/contrib/perf.py Mon Feb 19 11:43:19 2024 +0100 @@ -4303,6 +4303,11 @@ baserepo = repo.filtered(b'__perf_branchmap_update_base') targetrepo = repo.filtered(b'__perf_branchmap_update_target') + copy_base_kwargs = copy_base_kwargs = {} + if 'repo' in getargspec(repo.branchmap().copy).args: + copy_base_kwargs = {"repo": baserepo} + copy_target_kwargs = {"repo": targetrepo} + # try to find an existing branchmap to reuse subsettable = getbranchmapsubsettable() candidatefilter = subsettable.get(None) @@ -4311,7 +4316,7 @@ if candidatebm.validfor(baserepo): filtered = repoview.filterrevs(repo, candidatefilter) missing = [r for r in allbaserevs if r in filtered] - base = candidatebm.copy() + base = candidatebm.copy(**copy_base_kwargs) base.update(baserepo, missing) break candidatefilter = subsettable.get(candidatefilter) @@ -4321,7 +4326,7 @@ base.update(baserepo, allbaserevs) def setup(): - x[0] = base.copy() + x[0] = base.copy(**copy_target_kwargs) if clearcaches: unfi._revbranchcache = None clearchangelog(repo)