[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.technology.emft] Re: [EMF Compare] MergeService doesn't copy a child non-containment reference

Hi Stephen,

With two differences as you've described, EMF Compare will indeed need two steps for this child reference to be copied : you have an added element A with a reference towards the child C of another added element B. Merging only A will not copy C since B hasn't been copied yet, but merging B subsequently will copy C _and_ restore the link from A to C.

We've implemented the merge as such so has to only merge the differences the user selected, not ones that are not directly linked. MergeService is final as it simply isn't meant to be subclassed, but you can force EMF Compare to consider your two differences to be linked (and thus needing to be merged together) through the use of the org.eclipse.emf.compare.diff.extension extension point.

Laurent Goubet
Obeo

Stephen McCants a écrit :
Resending with proper subject line.
    --Stephen

-------- Original Message --------
Subject: MergeService doesn't copy a child non-containment reference
Date: Thu, 30 Jul 2009 13:39:39 -0500
From: Stephen McCants <stephenmccants@xxxxxxxxx>
Organization: EclipseCorner
Newsgroups: eclipse.technology.emft

Hello,

We have a model and are doing the match, diff and merge. Everything is working correctly, except
the merge fails to merge in one object.


The diff correctly identifies an object that has been added to the model. That added object has a
non-containment reference to another object. When we do the merge, it correctly copies the added
object to the left model (from the right model), but the non-containment reference is never set.
Instead of being set, it is null.


We traced through the copy code and it is trying to copy it in
EMFComapreEObjectCopier.copyReferences() by calling copyReference(). However, the call to
copyReference() does nothing because we haven't copied it before (so it isn't returned by get()) and
the mergeLinkedDiff() function returns false.


The reason mergeLinkedDiff() returns false is because the reference being copied is a child of an
unmatched element and not an unmatched element itself.


We were going to try to override the Copier and make some adjustments to work around this problem,
but there seems to be no way to do that (MergeService is final and MergeService.getCopier() always
uses the EMFCompareEObjectCopier()).


Any ideas on what we can do to get the MergeService to copy the non-containment reference over?

Thanks!

--Stephen

begin:vcard
fn:Laurent Goubet
n:Goubet;Laurent
org:<a href="http://www.obeo.fr/";>Obeo</a>
email;internet:laurent.goubet@xxxxxxx
url:http://www.obeo.fr
version:2.1
end:vcard