taskchampion
taskchampion copied to clipboard
Make `commit_reversed_operations` more capable.
Right now, this method (known as commit_undo_ops
before #372) just checks that the latest set of un-synchronized operations in the replica match the operations to undo. If that's the case, it removes them from the list of un-synchronized operations, reverses their effect on the tasks, and declares success. Otherwise, it fails.
This could be more robust -- if an operation does not precisely match the most recently recorded local operation, there's enough data to create a new, reversed operation (switch Create <--> Delete, swap value
and old_value
in Update) and commit that. Adding such support would be a big step on the way to allowing "undo" after a sync has occurred.
I think we should fail the commit_reversed_operations
if the reversed operation doesn't apply cleanly. So:
- A reversed Create is a Delete, but if the task doesn't exist, that should fail.
- A reversed Delete is a Create, but if the task still exists, that should fail.
- A reversed Update specifies the
old_value
it expects to find, but if the value is different, it should fail.