Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement merge with basic conflict handling (LeftToRIght & RightToLeft) #9

Open
jbsarrodie opened this issue Dec 5, 2023 · 3 comments

Comments

@jbsarrodie
Copy link
Member

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):

  1. 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 (using BatchMerger.copyAllLeftToRight())
  2. 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 (using BatchMerger.copyAllRightToLeft())
  3. Merge conflicting changes:
  4. Select conflicting changes
  5. Ask the user what to do with them in a global way (keep "our" changes or keep "their" changes)
  6. Based on answer to previous question, call either BatchMerger.copyAllLeftToRight() for "our" or BatchMerger.copyAllRightToLeft() for "their".
@jbsarrodie
Copy link
Member Author

Another remark related to my tests: when renaming a concept which is used on a view, in the list of differences, I get a change on the concept (expected), but also a change on DiagramModelArchimateObject instances related to this concept. Maybe there is some tuning to be done so that EMF Compare doesn't take such EMF classes into account.

@Phillipus
Copy link
Member

Another remark related to my tests: when renaming a concept which is used on a view, in the list of differences, I get a change on the concept (expected), but also a change on DiagramModelArchimateObject instances related to this concept. Maybe there is some tuning to be done so that EMF Compare doesn't take such EMF classes into account.

See #10

@jbsarrodie
Copy link
Member Author

@Phillipus I've implemented a basic merge operation which works as intended.

Still to be done:

  • Filter Diffs which should never been applied, such as those related to DiagramModelArchimateObject#name
  • Check what happens when solving conflicts in a way that would lead to a non integral model
  • Some nice UI :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants