Most of the commands in Pynsource are wrapped in command objects, which have an execute, undo and redo method.
This is a classic use of the Command design pattern.
Image courtesy of Wikipedia.
The undo operations in Pynsource are currently not implemented, but this will one day get done.
Here is a screenshot of the Pynsource app, which is a free desktop app (Mac, Windows, Linux) for reverse engineering Python source code into UML.
See the source code for Pynsource here on GitHub.
List of repository modules/files being visualised in the above diagram: