On Fri, May 18, 2012 at 6:54 PM, Vincent Massol <[email protected]> wrote:
Hi Thomas,
On May 15, 2012, at 5:49 PM, Thomas Mortagne wrote:
Hi devs,
Since there is not official standard for diff/merge API I started to write a simple one. Yo can find it on https://github.com/xwiki/xwiki-commons/tree/feature-diff/xwiki-commons-core/....
The first use case for it is to provide a diff/merge API for the Extension Manager XAR merging conflict resolution UI.
It is mostly inspired from JRCS/java-diff-utils APIs and implemented using java-diff-utils (http://code.google.com/p/java-diff-utils/) for the diff and JDiff (http://www.qarks.com/web/en/products_jdiff.html) for the multiline String merge. Theses are the most active independent libraries I could find so far and it's not really what I would call active library usually...
Would be nice to get some comments/suggestions on the API.
Similar to Ludovic's question, I'd like to ensure that we can refactor our current diff code to use this new API in the future.
Depends which code, refactoring the one returning JRCF API directly is useless. For all the rest in general anyway all we have is very simple diff on lines of String which is not very hard to put in a List<String>... Now I doubt it bring much to refactor them. Again all we have is very simple diff, we don't have anything to merge in old API.
For the implementation side if you know some good diff/merge tool I would be glad to get some other suggestions. I took a quick look at various EDIs which obviously have this kind of tools but what I could find is not really designed to be used easily outside of the EDI for which they have been designed. Either its very tied to the EDI itself or it's generic enough but trigger a whole bunch of dependencies while we would use like 1% of the total.
Here are the various features I'm looking for in an ideal library: * good 3 ways merge ("good" is not a detail, applying a patch on the third version does not always give very good results) * diff/patch API * support of single line in 3 ways merge and diff
What happens if we can't find a library?
We do it ourself.
How hard is it to implement a 3-way diff?
I don't think it's very hard. Plus we can look at what JDiff guys did for String lines which is not much different from any list of anything (at least for not much detail than the "line" is added/removed/modified which is already nice). We already do it ourself for anything but String right now in Extension Manager anyway. Whatever the object type it's always more or less the same idea.
Do we have other options?
I don't see any. Someone has to do it, if we can't find a library we'll do it. The alternative is to not try to merge anything basically and let the user always merge any modification by hand even when it's simple things which would be a pain IMO.
Thanks -Vincent
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne