[feat] Add rudimentary handling of content conflicts #19 #22
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
First attempt at doing something about #19
This is a pretty hacky solution to representing content conflicts. Note that content is e.g. the value of a literal, or the name of a method. The children of a node are not part of the content of a node.
Essentially, when two nodes are found to have conflicting content in revisions (more than one piece of content after merging has finished), it's represented as a merge conflict by simply replacing the content with a literal merge conflict. Then, the pretty-printer will just print it out without any fuzz, with newlines and all.
https://github.com/KTH/spork/blob/cec7468f46c42d7e78cebb654f4737e789194bd8/src/main/java/se/kth/spork/merge/spoon/SpoonPcs.java#L307-L347
This works under the assumption that all node contents in Spoon (e.g. literal values and method names and the like) are represented by actual Java
String
objects in the metamodel. This has so far proven correct, but I may be wrong on that account. It also assumes that each node has at most one piece of content. This may also be incorrect.A big drawback of this approach is that adjacent conflicts are represented as separate conflicts. Below is an example.
merging these revisions results in a conflict that looks something like this
but obviously, a conflict like this would be more desirable
This could be solved with text processing after the fact, or better yet with an entirely different approach to showing content conflicts.