开发者

Diff, compare and merge files - general concepts

开发者 https://www.devze.com 2023-03-05 18:12 出处:网络
Consider the example below without any assumption about language or file types. I have: M_old : [A,B,C]

Consider the example below without any assumption about language or file types. I have:

M_old : [A,B,C]
M_new : [A,B,X]

and now I would like to create:

M_result : [A,B,C,X]

which is basically the union of M_old and M_new. Are there any compare/diff/merge tool that supports this kind of operation - that can take M_old and M_new and produce M_result based on the above instances?

I have had success with computing (using a simple diff/merge tool) M_result when:

M_old : [A,B,C]
M_new : [A,B,C,X]

since all elements in M_old is contained in M_new. B开发者_JAVA百科ut I don't see how this possible when some of the elements in M_old is not present in M_new.

So in more general terms does a "merge" operation only support union under special conditions as described above?


If you don't care about the exact order of the resulting list, you can compute M_result by appending every element in M_old that is not in M_new to M_new, or, alternatively, by concatenating M_new and M_old and then removing duplicate elements (These yield the exact same result if neither input list contains any duplicate elements to begin with).


correct merge tools will propose you the solution that you want amongst other solutions, this is what our tool ECMerge does.

(I presume you have an ancestor: M_ancestor: [A,B]) your problem here is that there are not enough data to determine that is expected when there is a replacement (should the merge result be ',C' then ',X', ',X' then ',C' or only one or the other).

(I presume you have an ancestor: M_ancestor: [A,B,C]) the other case when the change is an insertion of ',X' (M_old : [A,B,C] versus M_new : [A,B,C,X]) is generally resolved by adding ',X' as there is no particular choice. if the ancestor is [A,B] only then there is still a question: should the merger consider adding ',C' or ',C,X' ? this is not obvious then as the version with only ',C' might have taken into account the knowledge of ',C,X' from outside the SCC system and already deleted the ',X'.

even 'clever' merger cannot do divination :)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号