wmde / Diff

䷂ Library for diffing, patching and representing differences between objects
BSD 3-Clause "New" or "Revised" License
200 stars 15 forks source link

Implement an order-aware MapDiffer #4

Closed JeroenDeDauw closed 7 years ago

JeroenDeDauw commented 10 years ago

Posted by Daniel Kinzler on 2013-12-10 14:55:12 UTC at https://bugzilla.wikimedia.org/show_bug.cgi?id=58274

One problem with implementing this is that following the naive approach (representing a change in order as a remove and an insert operation), both such operations would have the same key in the (Map)Diff, so one would override the other. Also, for the insert operation, it would need some context specifying where to insert it.

An alternative approach is to represent the order explicitly as a list of keys, and attach that list as an extra field to the MapDiff.

Note that the class tree based in the Diff class contains some overburdened and some deprecated classes. Some refactoring may be in order.

Also, care must be taken to allow for reliably application of Diffs as patches.

JeroenDeDauw commented 7 years ago

The original motivation for this was tracked at https://phabricator.wikimedia.org/T60274. Not clear this should be done in Diff at all, and not clear how this could be done nicely either.