[Openmcl-devel] What goes on under the hood during revert
Ron Garret
ron at flownet.com
Sun Jan 24 11:59:03 PST 2010
Trying to trace through the process of what happens when you revert a document...
The REVERT menu item invokes revertDocumentToSaved: (as can be determined with this handy-dandy little snippet):
? (%get-cstring (#_sel_getName (menu-item-action-selector "File" "Revert")))
"revertDocumentToSaved:"
As far as I can tell, this method is not overridden anywhere in the GUI sources, so this just does the standard Cocoa thing, namely, displays the "Are you sure?" dialog, and then invokes....
... and that's where I get very puzzled, because the latest docs say it invokes revertToContentsOfURL:ofType:error:, which is also, as far as I can tell, not overridden anywhere. What *is* overridden is revertToSavedFromFile:ofType: but that method is deprecated in Leopard, and as far as I can tell (by adding a print statement) this method is in fact not invoked when a file is reverted.
OK, so maybe the code overriding revertToSavedFromFile:ofType: is just dead code in Leopard, but it sure seems to do an awful lot of work. It seems improbable to me that all that code just fall on the floor without causing some negative repercussions. But what do I know?
Any light that anyone can shed on this would be much appreciated. I'm as much interested in learning how I should be approaching a situation like this in general as I am about getting the specific answer in this case -- teach a man to fish and all that.
Just to put this in context, what I'm really trying to do is integrate a revision control system into the GUI to automatically take snapshots of files whenever you save them, and then let you roll back through the save history. I figure the easiest way to do rollback is to use the RCS to rollback the underlying file, and then revert the buffer. But maybe that's not the best way to do it. Cocoa seems to be doing a lot of stuff behind the scenes that could break assumptions about the correspondence between files and Hemlock editor buffers, which is the reason I want to make sure I understand how things currently work before starting to hack it.
Thanks,
rg
More information about the Openmcl-devel
mailing list