Mercurial > hg
changeset 51523:ef369d16965d
branchcache: cleanup the final key generation after update
A lot of duplicated work seemed to be done, as we already update the tiprev and
tipnode when needed right before. So we simplify that part to focus on the
filtered hash.
See inline comment for details.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Sun, 25 Feb 2024 23:31:50 +0100 |
parents | 5f9350956c03 |
children | 4bfae99c4021 |
files | mercurial/branchmap.py |
diffstat | 1 files changed, 14 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/branchmap.py Wed Feb 28 12:56:08 2024 +0100 +++ b/mercurial/branchmap.py Sun Feb 25 23:31:50 2024 +0100 @@ -698,26 +698,22 @@ if max_rev is not None and max_rev > self.tiprev: self.tiprev = max_rev self.tipnode = cl.node(max_rev) + else: + # We should not be here is if this is false + assert cl.node(self.tiprev) == self.tipnode if not self.validfor(repo): - # old cache key is now invalid for the repo, but we've just updated - # the cache and we assume it's valid, so let's make the cache key - # valid as well by recomputing it from the cached data - self.tipnode = repo.nullid - self.tiprev = nullrev - for heads in self.iterheads(): - if not heads: - # all revisions on a branch are obsolete - continue - # note: tiprev is not necessarily the tip revision of repo, - # because the tip could be obsolete (i.e. not a head) - tiprev = max(cl.rev(node) for node in heads) - if tiprev > self.tiprev: - self.tipnode = cl.node(tiprev) - self.tiprev = tiprev - self.filteredhash = scmutil.filteredhash( - repo, self.tiprev, needobsolete=True - ) + # the tiprev and tipnode should be aligned, so if the current repo + # is not seens as valid this is because old cache key is now + # invalid for the repo. + # + # However. we've just updated the cache and we assume it's valid, + # so let's make the cache key valid as well by recomputing it from + # the cached data + self.filteredhash = scmutil.filteredhash( + repo, self.tiprev, needobsolete=True + ) + self._state = STATE_DIRTY tr = repo.currenttransaction() if getattr(tr, 'finalized', True):