Solving merge Conflicts in drupal8 - GSoC16 - Week9

Submitted by rakesh on Wed, 07/27/2016 - 22:02

It's been 3 months now and we're finally approaching the last steps of our project - "Solving Merge conflict in Drupal 8" with Multiversion module. So far, we have launched two Open source Libraries, Implemented Simple LCA resolver and a simple merge resolver in the Conflict  module to find lowest common ancestor and merge the updates respectively. Now all development phase is almost done and the integration part starts where we have to integrate the Libraries we created in the first phase of Google Summer of Code16. The libraries we created were relaxed/lca and relaxed/merge

Let's take a look at the project's target and the solution we are implemeting:

Project Details: With the introduction of Multiversion module in Drupal 8, we have a very powerful content revision API that can handle branching and conflict DETECTION. But there is not yet a way to SOLVE revision conflicts.

Proposed Solution: We store a graph of all the updated revisions from an entity and find a base revision from this graph with which two entities can be compared. This process is based on 3-way merge algorithm. According to this algorithm, we shall compare two revisions of an entity with another revision or actual node to detect what has been modified in those revisions. If the new revisions has modified content over different lines, the updated content shall be merged in the new revision along with the unchanged data from previous revisions. This is why we compare two entities with a base entity, to find out which part has been modified in the new revisions. If both the new revisions has modified the same data, a merge conflict would occur and user would be allowed to solve the conflict in a 3-pane window. You can find more about the project and the approach in the 3rd week blog post at my blog.

Work we did last week: The multiversion module stores the revision status and other data in form of trees. To detect and solve conflicts, we need to convert this data in graphs. Last week, we worked on writing code which could create a graph from a given tree.

We wrote a recursive function to store all revision Ids from the tree in an array. Then we created nodes from those revision IDs. After the recursive function extracted the revision ID correctly, we wrote a function which creates edges between these nodes in the exact same manner in which they were connected in the tree. The code is pushed here.

Work we did this week: We tested the code we developed last week for the Conflict Module to convert the tree returned by getTree method of Multiversion module. After we made sure it’s returning the expected output, we merged the code into Multiversion module as a new method named getGraph. Other than that, we have written tests for it in the multiversion module as well to ensure it’s functionality with the module. We also implemented Travis CI integration for the conflict module. We’re also making sure that our code is working on other versions of drupal than 8.2. All the code is pushed here.

Target for the next week: We will start with creating a complex LCA resolver which will use the relaxedws/lca library for finding LCA. This resolver will be available to only those sites which uses multiversion module and so we will implement this resolver in multiversion module only. We’d also be writing tests for the complex LCA resolver this week only.