Keep your code changes in an isolated checkout.
Recent revisions are kept. Restoring one creates a new revision.