couchbaselabs/CouchCocoa — pull request #35 by robin (2012-08-05 16:10:07+00:00)
Title: document should always choose the highest revision as current revision

Sometime, a document may have a conflict revision with lower revision number but higher sequence number. If db.tracksChanges is set to YES, after the first sync, the document chooses the revision with the higher sequence number as the current revision instead of the higher revision number, which might be wrong.

addressing comment from @snej

> This is a great fix, except that the comparison algorithm for revision IDs is a bit more complex. (The numeric prefixes before the "-" need to be compared numerically, otherwise "10-" sorts as lower than "2-".) TouchDB has an implementation of this: the function TDCollateRevIDs() in TDRevision.m. You can just copy that into CouchCocoa for this purpose.
>
> PS: After making the change please rebase your commits into one instead of adding another commit to the pull request.