phases: improve performance of _retractboundary
The old version repeatedly converts nodes to revisions, which is a
moderately expensive operation. Mapping all new changes once to
revisions and back at the end reduces the time spend in _retractboundary
during the unbundling of NetBSD's src from 67s to 17s.
Differential Revision: https://phab.mercurial-scm.org/D8641