581 name = phasenames[targetphase] |
581 name = phasenames[targetphase] |
582 msg = b'this repository does not support the %s phase' % name |
582 msg = b'this repository does not support the %s phase' % name |
583 raise error.ProgrammingError(msg) |
583 raise error.ProgrammingError(msg) |
584 |
584 |
585 repo = repo.unfiltered() |
585 repo = repo.unfiltered() |
586 currentroots = self.phaseroots[targetphase] |
586 torev = repo.changelog.rev |
|
587 tonode = repo.changelog.node |
|
588 currentroots = {torev(node) for node in self.phaseroots[targetphase]} |
587 finalroots = oldroots = set(currentroots) |
589 finalroots = oldroots = set(currentroots) |
|
590 newroots = [torev(node) for node in nodes] |
588 newroots = [ |
591 newroots = [ |
589 n for n in nodes if self.phase(repo, repo[n].rev()) < targetphase |
592 rev for rev in newroots if self.phase(repo, rev) < targetphase |
590 ] |
593 ] |
|
594 |
591 if newroots: |
595 if newroots: |
592 |
596 if nullrev in newroots: |
593 if nullid in newroots: |
|
594 raise error.Abort(_(b'cannot change null revision phase')) |
597 raise error.Abort(_(b'cannot change null revision phase')) |
595 currentroots = currentroots.copy() |
|
596 currentroots.update(newroots) |
598 currentroots.update(newroots) |
597 |
599 |
598 # Only compute new roots for revs above the roots that are being |
600 # Only compute new roots for revs above the roots that are being |
599 # retracted. |
601 # retracted. |
600 minnewroot = min(repo[n].rev() for n in newroots) |
602 minnewroot = min(newroots) |
601 aboveroots = [ |
603 aboveroots = [rev for rev in currentroots if rev >= minnewroot] |
602 n for n in currentroots if repo[n].rev() >= minnewroot |
604 updatedroots = repo.set(b'roots(%ld::)', aboveroots) |
603 ] |
605 |
604 updatedroots = repo.set(b'roots(%ln::)', aboveroots) |
606 finalroots = {rev for rev in currentroots if rev < minnewroot} |
605 |
607 finalroots.update(ctx.rev() for ctx in updatedroots) |
606 finalroots = {n for n in currentroots if repo[n].rev() < minnewroot} |
|
607 finalroots.update(ctx.node() for ctx in updatedroots) |
|
608 if finalroots != oldroots: |
608 if finalroots != oldroots: |
609 self._updateroots(targetphase, finalroots, tr) |
609 self._updateroots( |
|
610 targetphase, {tonode(rev) for rev in finalroots}, tr |
|
611 ) |
610 return True |
612 return True |
611 return False |
613 return False |
612 |
614 |
613 def filterunknown(self, repo): |
615 def filterunknown(self, repo): |
614 """remove unknown nodes from the phase boundary |
616 """remove unknown nodes from the phase boundary |