Mercurial > hg-stable
diff mercurial/phases.py @ 51399:8f2ea3fa50fd
phases: explicitly filter stripped revision at strip time
Explicit is better than implicit. The current logic is bit subtle and fragile.
It also get in the way of using something else than node-id as internal storage.
We replace it with a more explicit filtering while striping.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Tue, 20 Feb 2024 14:21:18 +0100 |
parents | f4a0806081f2 |
children | 68289ed170c7 |
line wrap: on
line diff
--- a/mercurial/phases.py Fri Feb 23 04:26:03 2024 +0100 +++ b/mercurial/phases.py Tue Feb 20 14:21:18 2024 +0100 @@ -702,6 +702,24 @@ return True return False + def register_strip( + self, + repo: "localrepo.localrepository", + tr, + strip_rev: int, + ): + """announce a strip to the phase cache + + Any roots higher than the stripped revision should be dropped. + """ + assert repo.filtername is None + to_rev = repo.changelog.index.rev + for targetphase, nodes in list(self.phaseroots.items()): + filtered = {n for n in nodes if to_rev(n) >= strip_rev} + if filtered: + self._updateroots(targetphase, nodes - filtered, tr) + self.invalidate() + def filterunknown(self, repo: "localrepo.localrepository") -> None: """remove unknown nodes from the phase boundary