comparison mercurial/phases.py @ 51410:eababb7b4a82

phases: leverage the collected information to record phase update Since the lower level function already gather this information, we can directly use it. This comes with a small change to the test that are actually fixing them. The previous version over-reported some phase change that did not exists. In both case, we are force revision `1` to be secret and `0` remains draft`, the previous code wrongly reported `0` as moving to secret while it properly remained draft in the repository.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 20 Feb 2024 23:46:21 +0100
parents 2f39c7aeb549
children 774e4eff6e47
comparison
equal deleted inserted replaced
51409:2f39c7aeb549 51410:eababb7b4a82
643 self._retractboundary(repo, tr, targetphase, revs=delroots) 643 self._retractboundary(repo, tr, targetphase, revs=delroots)
644 repo.invalidatevolatilesets() 644 repo.invalidatevolatilesets()
645 return changes 645 return changes
646 646
647 def retractboundary(self, repo, tr, targetphase, nodes): 647 def retractboundary(self, repo, tr, targetphase, nodes):
648 oldroots = {
649 phase: revs
650 for phase, revs in self._phaseroots.items()
651 if phase <= targetphase
652 }
653 if tr is None: 648 if tr is None:
654 phasetracking = None 649 phasetracking = None
655 else: 650 else:
656 phasetracking = tr.changes.get(b'phases') 651 phasetracking = tr.changes.get(b'phases')
657 repo = repo.unfiltered() 652 repo = repo.unfiltered()
658 retracted = self._retractboundary(repo, tr, targetphase, nodes) 653 retracted = self._retractboundary(repo, tr, targetphase, nodes)
659 if retracted and phasetracking is not None: 654 if retracted and phasetracking is not None:
660 655 for r, old_phase in sorted(retracted.items()):
661 # find the affected revisions 656 _trackphasechange(phasetracking, r, old_phase, targetphase)
662 new = self._phaseroots[targetphase]
663 old = oldroots[targetphase]
664 affected = set(repo.revs(b'(%ld::) - (%ld::)', new, old))
665
666 # find the phase of the affected revision
667 for phase in range(targetphase, -1, -1):
668 if phase:
669 roots = oldroots.get(phase, [])
670 revs = set(repo.revs(b'%ld::%ld', roots, affected))
671 affected -= revs
672 else: # public phase
673 revs = affected
674 for r in sorted(revs):
675 _trackphasechange(phasetracking, r, phase, targetphase)
676 repo.invalidatevolatilesets() 657 repo.invalidatevolatilesets()
677 658
678 def _retractboundary(self, repo, tr, targetphase, nodes=None, revs=None): 659 def _retractboundary(self, repo, tr, targetphase, nodes=None, revs=None):
679 if targetphase == public: 660 if targetphase == public:
680 return {} 661 return {}