iCloud: Strategy to merge two versions of a file package (common ancestor)?

203 views Asked by At

I have a document based app (Mac & iOS) and am trying to find a good way to automatically resolve version conflicts without bothering the user.

My document is actually a file package with lots of small notes stored as text files. The most likely scenario of a version conflict is that a user modifies a different note on each device so I should be able to merge them by just picking the most recent one of each.

However, with NSFileVersion I only get the current (most recent) and the conflict version, but I need to know the modification date of the common ancestor in order to know that I can use a note without losing changes.

Example flow:

Both clients start with note1.txt: base

   Client 1         Client 2    
--------------  ----------------
                 note1.txt: foo
note1.txt: bar
                 note2.txt: hey

Based on the above, the version of client 2 would become the current, because note2.txt was the most recent save operation.

In the above case I can't simply merge in the most recent version of note1.txt, because I would lose the change that client 2 made ("foo"). I need to first look at note1.txt of client 2 and tell if that was modified compared to the common ancestor ("base").

It would be a simple & elegant solution, but I think that this is not possible to do with NSFileVersion alone unless I'm missing something.

An alternative would be to use some sort of timestamped transaction log, but this would complicate things quite a bit...

0

There are 0 answers