Extension:MirrorTools/Pagedelete, mirrorpagedelete, pagerestore, and mirrorpagerestore

Neither locally nor remotely controlled revisions present at target page
Impossible to delete, because there are no revisions to delete.

Only locally controlled revisions present at target page
Delete as normal.

Only remotely controlled revisions present at target page
Impossible to delete, because remotely controlled pages and revisions can't be deleted locally.

Both locally and remotely controlled revisions present at target page
Impossible to delete, because remotely controlled pages and revisions can't be deleted locally.

Neither locally nor remotely controlled revisions present at target page
Impossible to mirrordelete, because there are no revisions to mirrordelete.

Only locally controlled revisions present at target page
Impossible to mirrordelete, because there must be remotely controlled revisions present in order to do a mirrordelete.

Only remotely controlled revisions present at target page
Mirrordelete as normal.

Both locally and remotely controlled revisions present at target page
Mirrordelete only the remotely controlled revisions.

Neither locally nor remotely controlled revisions present at target page
Undelete as normal.

Only locally controlled revisions present at target page
Undelete as normal.

Only remotely controlled revisions present at target page
Undelete as normal.

Both locally and remotely controlled revisions present at target page
Undelete as normal.

Neither locally nor remotely controlled revisions present at target page
Mirrorundelete as normal.

Only locally controlled revisions present at target page
Undelete to page id specified by remote wiki. Change local revisions over to that if necessary.

Only remotely controlled revisions present at target page
Mirrorundelete as normal.

Both locally and remotely controlled revisions present at target page
Mirrorundelete as usual.

MirrorPageDelete

 * See if this data is already in the logging or recentchanges tables; if so, die
 * Make any remotely live revisions that are at that deleted page not remotely live anymore
 * Update the page table entry for the deleted page, to make it not remotely live
 * Find the parent ID, sorting descending by timestamp and then rev_id
 * Create null revision
 * To find the page_latest, sort descending by timestamp and then rev_id
 * Insert log and recent changes entries

MirrorPageRestore
Step 4 is to push all the mirroredit items and step 5 is to push the log event.