I tried to just run as many undo steps as I had made "erase" commands, but only the erase commands that actually erase something change the undo buffer, the erase commands that try to erase something that isn't there dont change the undo buffer, and I dont know how many actually do, since erase does not tell me whether it did something or not, so I dont know how many undo steps I need exactly to get to the exact checkpoint where I need to go back. I don't need the undo buffer history before the checkpoint, so I could either clear the undo buffer when I reach a checkpoint, or I would need some way to figure out how many steps I need to undo to get there.