LMS-11185 Split implementation of revert_to_published

@dmitchell Please review.
Since revert is recursive, do you really want to skip DIRECT_ONLY?