A rollback is a dangerous option and should always be considered carefully. And yes, I've screwed this up myself at least once, so don't beat-up yourself too much about it either.
The entire point of a rollback is to prevent a question and answer being out-of-sync. So, a rollback causing this, is not a good situation.
Does the question need to be rolled forward?
It very likely has to be fixed one way or another. I'm currently looking into the possibilities.
Update: left a comment and rolled back the rollback. Seemed like the sensible thing to do.
Do we discourage people from significant question rewriting even before answers are received?
In general? No. Although if people keep posting updates before the answer is posted it might turn the question into a mess. But consider the following scenario.
A question has been posted 3 weeks ago. No answers have arrived. Now, the OP has rewritten and improved it locally and wants to have the new code reviewed. Obvious solutions would include:
- Removing the original question (it no longer serves a purpose) and posting a new question.
- If the original questions has acquired a positive score over time, the likelihood of this happening is remote.
- Keeping both the original question and posting a new question.
- Now there's 2 questions, both unanswered and reviewing the original no longer feels like helping as much. After all, it's no longer relevant. People might still learn from it, yes, but the value of the answers are unavoidably reduced.
- Edit the original question. No answers have been posted yet, so there's no problem. It's also the SE way of dealing with such questions, although there's many forms of rewrites. Completely wiping the question and replacing it by something else would be odd at best, vandalism at worst. But including an update clarifying how the code has already been improved, sure, that's fine.
So, do we discourage rewrites? No, but not all rewrites are equal. This one was fine.