Add revert_to_published method.

STUD-1860

OK, @dmitchell has patiently helped me through writing this method. Please review, @dmitchell and @nasthagiri.
OK, I'll switch it. Though I don't think that we need to optimize this sort of operation, as it rarely happens and is triggered by the user with appropriate "in progress" notifications.