Skip to content

Commit

Permalink
Merge branch 'update-import' of github.com:benedikt-schesch/AST-Mergi…
Browse files Browse the repository at this point in the history
…ng-Evaluation into update-import
  • Loading branch information
benedikt-schesch committed May 4, 2024
2 parents c5e74ad + c9472e8 commit cb032dd
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 10 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/small-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jobs:
test:
strategy:
matrix:
maven: [ '3.9.2']
maven: [ '3.9.2' ]
runs-on: ubuntu-latest
defaults:
run:
Expand Down Expand Up @@ -52,6 +52,7 @@ jobs:
maven-version: ${{ matrix.maven }}
- name: Clean caches & workspace
run: make clean
- run: echo "LOGURU_COLORIZE=NO" >> $GITHUB_ENV
- name: Run small test
run: |
git config --global user.email "[email protected]"
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,5 @@ To run style checking run `make style`.
## Comparing merge algorithms

To investigate differences between two mergers:
* run `src/python/select_from_results.py` to produce a CSV file containing only the differences you are interested in.
* run `` to create a .csv database containing only the differences.
* run `src/python/select_from_results.py` to produce a CSV file containing only the differences you are interested in. See its [documentation (at top of file)](src/python/select_from_results.py) for how to run it.
* run `src/python/replay_merge.py --merges_csv CSV_FILE --idx INDEX` (maybe add `-test`) for the index of the merge you are interested in.
20 changes: 14 additions & 6 deletions src/python/replay_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,9 @@ def merge_replay(

if (WORKDIR_DIRECTORY / workdir).exists():
# Ask the user if they want to delete the workdir
print(
f"workdir {workdir} already exists. Do you want to delete it? (y/n)"
answer = input(
f"workdir {workdir} exists. Delete it (n=reuse it)? (y/n)"
)
answer = input()
if answer == "y":
shutil.rmtree(WORKDIR_DIRECTORY / workdir)
else:
Expand Down Expand Up @@ -107,7 +106,10 @@ def merge_replay(
log_path,
repo.local_repo_path,
]
if merge_data[f"{merge_tool.name}_merge_fingerprint"] != merge_fingerprint:
if (
merge_data[f"{merge_tool.name}_merge_fingerprint"] != merge_fingerprint
and not arguments.dont_check_fingerprints
):
raise Exception(
f"fingerprints differ: after merge of {workdir} with {merge_tool}, found"
+ f" {merge_fingerprint} but expected "
Expand Down Expand Up @@ -170,7 +172,7 @@ def merge_replay(
"--merges_csv",
help="CSV file with merges that have been tested",
type=str,
default="results/small/result.csv",
default="results/combined/result.csv",
)
parser.add_argument(
"--idx",
Expand All @@ -183,11 +185,17 @@ def merge_replay(
help="Test the replay of a merge",
action="store_true",
)
parser.add_argument(
"--dont_check_fingerprints",
help="Don't check the fingerprint of a merge",
default=False,
action="store_true",
)
arguments = parser.parse_args()

# Setup for imports
os.system(
"./src/scripts/merge_tools/merging/gradlew -p src/scripts/merge_tools/merging shadowJar"
"./src/scripts/merge_tools/merging/gradlew -q -p src/scripts/merge_tools/merging shadowJar"
)
os.environ["PATH"] = os.environ["PATH"] + os.getcwd() + "/src/scripts/merge_tools/:"
os.environ["PATH"] = (
Expand Down
17 changes: 16 additions & 1 deletion src/python/select_from_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
Here are example invocations:
select_from_results.py '(gitmerge_ort == "Merge_failed") and (spork != "Merge_failed")'
select_from_results.py '(gitmerge_ort == "Merge_failed") != (spork == "Merge_failed")'
The resulting .csv is useful for manual examination but cannot be passed to
`replay_merge.py` because that requires a .csv file with all tools and all
fingerprints.
"""

import argparse
Expand Down Expand Up @@ -62,9 +66,20 @@ def main():

# Select some columns
columns_to_select = (
["idx", "repo-idx", "merge-idx", "branch_name", "merge", "left", "right"]
[
"idx",
"repo-idx",
"merge-idx",
"branch_name",
"merge",
"left",
"left_tree_fingerprint",
"right",
"right_tree_fingerprint",
]
+ columns_in_query(args.query)
+ args.columns
+ ["repository"]
)
df = df[columns_to_select]

Expand Down

0 comments on commit cb032dd

Please sign in to comment.