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

[feat] Add rudimentary handling of content conflicts #19 #22

Merged
merged 1 commit into from
Feb 20, 2020

Conversation

slarse
Copy link
Collaborator

@slarse slarse commented Feb 20, 2020

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.

// assume the base revision has this method header
public int add(int a, int b)

// assume the left revision changes it like so
public long adding(int a, int b)

// assume the right revision changes it like so
public double sum(int a, int b)

merging these revisions results in a conflict that looks something like this

public
>>>>>>> LEFT
long
=======
double
<<<<<<< RIGHT
>>>>>>> LEFT
adding
=======
sum
<<<<<<< RIGHT
(int a, int b)

but obviously, a conflict like this would be more desirable

public
>>>>>>> LEFT
long adding
=======
double sum
<<<<<<< RIGHT
(int a, int b)

This could be solved with text processing after the fact, or better yet with an entirely different approach to showing content conflicts.

This is pretty hacky, see source code comments in SpoonPcs class
@slarse slarse merged commit 1087270 into master Feb 20, 2020
@slarse slarse deleted the issue/19-handle-content-conflicts branch February 24, 2020 18:00
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

Successfully merging this pull request may close these issues.

1 participant