Add revert_to_published method.

STUD-1860

OK, @dmitchell has patiently helped me through writing this method. Please review, @dmitchell and @nasthagiri.
I'm super lazy these days. I'll let someone else add the method, as I'm not clear what you mean in the last comment.