Is it no longer possible to leave comments on the Wiki? This seems like a weird thing to start a Talk thread about, and there’s no “Wiki” or “Documentation” category on Talk…
#lastP : a last saved hash code of the parent instance object.
The conflict is detected when #lastP != NULL && ((#lastP != #P) || (#lastP != c)).
Should that read #lastP != NULL && (#lastP != #P && #lastP != #C) (or, equivalently, #lastP != NULL && (!(#lastP == #P || #lastP == #C))? As it is, it seems to read “a conflict is detected if either the parent or the child disagree with the previous parent” rather than “a conflict is detected if both the parent and the child disagree with the previous parent,” which is what I would expect.
The lastP store the last (after each synchronization action) hash code of each object. It is used because we need to know where the object was changed (on parent/on child/on both). Note that we don’t store the history for each object. Now if you know that only the parent’s representation was changed you know that this is the newest representation.
If we will use only parent’s and child’s hash code then the conflict will be always detected.
If the detection conflict mechanism proposed by us didn’t meet your expectation feel free to add alternative mechanism (and make sure that the user can choose which mechanism will be used via a setting or Sync configuration).
On this stage we want to know if any object was changed (so the expression could be simplified and check only differences between #P and #C).
The more specific information about which exactly objects was changed is useful when we try to resolve the conflict. When we, for instance, know that only child object was changed then we can choose this representation as newest and resolve the conflict automatically. Of course if we will know that both parent and child objects were changed then we need to resolve the conflict manually (or if possible we can use the date of update). I hope now it will be more clear.
For sure the expression (when we try to detect the conflict/changes) could be simplified. I’ve created the ticket for changing that in Project Backlog (https://issues.openmrs.org/browse/SYNCT-324). Thank you for your feedback.