Mercurial > public > mercurial-scm > hg
comparison mercurial/branchmap.py @ 51520: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 | 0d4a6ab3c8da |
children | a03fa40afd01 |
comparison
equal
deleted
inserted
replaced
51519:5f9350956c03 | 51520:ef369d16965d |
---|---|
696 # new tip revision which we found after iterating items from new | 696 # new tip revision which we found after iterating items from new |
697 # branches | 697 # branches |
698 if max_rev is not None and max_rev > self.tiprev: | 698 if max_rev is not None and max_rev > self.tiprev: |
699 self.tiprev = max_rev | 699 self.tiprev = max_rev |
700 self.tipnode = cl.node(max_rev) | 700 self.tipnode = cl.node(max_rev) |
701 else: | |
702 # We should not be here is if this is false | |
703 assert cl.node(self.tiprev) == self.tipnode | |
701 | 704 |
702 if not self.validfor(repo): | 705 if not self.validfor(repo): |
703 # old cache key is now invalid for the repo, but we've just updated | 706 # the tiprev and tipnode should be aligned, so if the current repo |
704 # the cache and we assume it's valid, so let's make the cache key | 707 # is not seens as valid this is because old cache key is now |
705 # valid as well by recomputing it from the cached data | 708 # invalid for the repo. |
706 self.tipnode = repo.nullid | 709 # |
707 self.tiprev = nullrev | 710 # However. we've just updated the cache and we assume it's valid, |
708 for heads in self.iterheads(): | 711 # so let's make the cache key valid as well by recomputing it from |
709 if not heads: | 712 # the cached data |
710 # all revisions on a branch are obsolete | 713 self.filteredhash = scmutil.filteredhash( |
711 continue | 714 repo, self.tiprev, needobsolete=True |
712 # note: tiprev is not necessarily the tip revision of repo, | 715 ) |
713 # because the tip could be obsolete (i.e. not a head) | 716 |
714 tiprev = max(cl.rev(node) for node in heads) | |
715 if tiprev > self.tiprev: | |
716 self.tipnode = cl.node(tiprev) | |
717 self.tiprev = tiprev | |
718 self.filteredhash = scmutil.filteredhash( | |
719 repo, self.tiprev, needobsolete=True | |
720 ) | |
721 self._state = STATE_DIRTY | 717 self._state = STATE_DIRTY |
722 tr = repo.currenttransaction() | 718 tr = repo.currenttransaction() |
723 if getattr(tr, 'finalized', True): | 719 if getattr(tr, 'finalized', True): |
724 # Avoid premature writing. | 720 # Avoid premature writing. |
725 # | 721 # |