Table of Contents
Source code merging has always been an issue for developers. When colloborating on complex projects, developers must inevitably use multiple branches, which is the cause for numerous merge conflicts. These conflicts often waste a lot of their time.
Existing 3-way merge algorithms developed by Git rely on textual difference, which often leads it to incorrectly resolve the conflicts or cause merge conflicts.
Other 3-way merge algorithms such as JDime or Spork take a strucutred approach which use Abstract Syntax Trees, however are limited in the scope in which they can be used.
As such, our purpose is to develop a new 3-way merge tool for Python and Java Source Code.
Mainly focused on Java & Python code to develop a general data structure that can represent statically & dynamically typed languages.
We used the CST (Concrete Syntax Tree) generated by Tree-Sitter (for Java), and the AST (Abstract Syntax Tree) generated using Python's ast library to provide the prelimary code structures. We then queried the Syntax Trees to construct our Abstract Data Structure.
This is relevant to CompressedTree and MethodUnion tools.
Our tools use the following heuristics:
- Python
-
Before using any tool or any script, install all the dependencies using
pipenv
pipenv install
-
Then, start a pipenv shell from which you can navigate the project, and run any scripts:
pipenv shell
- The extracting-scripts directory contains all the tools needed to extract case studies from various github repositories
- The merge-algorithms directory includes all the merge tools that were developed in this project. The two main tools being CompressedTree and MethodUnion.
- The demos directory includes all the case studies that were tested, and the overall results obtained from this project. It also contains the next steps for the MethodUnion tool, that we couldn't yet get to.
python3 <path to alg init.py> --left <left parent path> --right <right parent path> --base <base file path> --out <output file>
- Assumption: Input files are of correct syntax. Tools will not work with incorrect syntax.
- Create a .gitattributes file in your repo
- add following lines to it
*.java merge=gitadv
*.py merge=gitadv
- Run command
git config --global --edit
- Add following lines to config file
[merge "gitadv"]
name = gitadv
driver = python3 /path/to/repo/git-merge-adv/merge-algorithms/CompressedTree/init.py --left %A --right %B --base %O --output %A --file %P
- Sebastien Mosser - mossers@mcmaster.ca
- Madhur Jain - 21112002mj@gmail.com
- Nirmal Chaudhari - chaudn12@mcmaster.ca
- Parts of scripts obtained from [https://github.com/ace-design/git-corpus]
- All Case Studies for Java obtained from Awesome Java List: [https://github.com/akullpp/awesome-java]
- All Case Studies for Python Obtained from Awesome Python List:[https://github.com/vinta/awesome-python]
- CST generated using Tree-Sitter [https://github.com/tree-sitter/tree-sitter]
- Demo comparisons done using Gumtree [https://github.com/GumTreeDiff/gumtree]
Distributed under the MIT License. See LICENSE.txt for more information.