-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
I've finally tested coArchi 2 and looked at how RefreshModelAction handles merge. When some conflicts are detected at git level, or if a successful git merge led to an invalid model, the merge is managed by MergeHandler#handle3WayMerge(), mainly through these lines of code:
IComparisonScope scope = new DefaultComparisonScope(ourModel, theirModel, baseModel);
Comparison comparison = EMFCompare.builder().build().compare(scope);
List<Diff> differences = comparison.getDifferences();
Registry mergerRegistry = RegistryImpl.createStandaloneInstance();
IBatchMerger merger = new BatchMerger(mergerRegistry);
// Copy theirs into ours
merger.copyAllRightToLeft(differences, new BasicMonitor());From my tests, this leads to local (ie. Left) changes being discarded because only changes done on the remote end (ie. Right) are applied to the Common Ancestor and then saved as the Left model. So it seems we have to implement the following (loosely based on this code and this one too):
- Select non conflicting changes coming from Left (using a filter based on
and(fromSide(DifferenceSource.LEFT), not(hasConflict(ConflictKind.REAL)))) and applying them to common Ancestor (usingBatchMerger.copyAllLeftToRight()) - Select non conflicting changes coming from Right (using a filter based on
and(fromSide(DifferenceSource.RIGHT), not(hasConflict(ConflictKind.REAL)))) and applying them to common Ancestor (usingBatchMerger.copyAllRightToLeft()) - Merge conflicting changes:
- Select conflicting changes
- Ask the user what to do with them in a global way (keep "our" changes or keep "their" changes)
- Based on answer to previous question, call either
BatchMerger.copyAllLeftToRight()for "our" orBatchMerger.copyAllRightToLeft()for "their".
Phillipus and janesser
Metadata
Metadata
Assignees
Labels
No labels