Skip to content

Commit

Permalink
Merge branch 'adjacent-plus-plumelib' of github.com:mernst/AST-Mergin…
Browse files Browse the repository at this point in the history
…g-Evaluation into adjacent-plus-plumelib
  • Loading branch information
mernst committed Sep 22, 2024
2 parents 53c86f2 + 08eee89 commit 22f829e
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 10 deletions.
22 changes: 20 additions & 2 deletions src/python/replay_merge.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""Replay merges and their test results.
The output appears in the .workdirs/ directory.
The output appears in the `.workdirsf`/ directory.
Logs appear in the `replay_logs/merges/` directory.
Command-line arguments are listed just after the line:
if __name__ == "__main__":
Expand All @@ -13,6 +14,7 @@
import argparse
import git
import os
import os.path
import sys
import tarfile
from pathlib import Path
Expand Down Expand Up @@ -92,7 +94,22 @@ def merge_replay(
plumelib_merging_dir = Path(ast_merging_evaluation_repo.working_tree_dir) / Path(
"src/scripts/merge_tools/merging"
)
subprocess.run(["./gradlew", "-q", "shadowJar"], cwd=plumelib_merging_dir)
print(f"About to compile in {plumelib_merging_dir}")
p = subprocess.run(
["./gradlew", "-q", "shadowJar"],
cwd=plumelib_merging_dir,
capture_output=True,
text=True,
)
if p.returncode != 0:
print("Failure in: ./gradlew -q shadowJar")
print(p.stdout)
print(p.stderr)
sys.exit(1)
p = subprocess.run(
["./gradlew", "-q", "nativeCompile"], cwd=plumelib_merging_dir, check=False
)
print("Finished compiling")

result_df = pd.DataFrame()
with Progress(
Expand Down Expand Up @@ -157,6 +174,7 @@ def merge_replay(
["git", "merge-base", merge_data["left"], merge_data["right"]],
cwd=repo.local_repo_path,
stdout=subprocess.PIPE,
check=True,
)
.stdout.decode("utf-8")
.strip()
Expand Down
9 changes: 7 additions & 2 deletions src/python/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -568,13 +568,18 @@ def merge(
str(timeout),
f"src/scripts/merge_tools/{tool.name}.sh {self.local_repo_path.resolve()} {LEFT_BRANCH_NAME} {RIGHT_BRANCH_NAME}",
]
logger.debug(
f"merge: Merging {self.repo_slug} {left_commit} {right_commit} with {tool.name}"
)
p = subprocess.run(
command,
capture_output=True,
check=False,
)
std_streams = stdout_and_stderr(command, p)
logger.debug(std_streams)
if p.returncode == 124: # Timeout
explanation = explanation + "\n" + stdout_and_stderr(command, p)
explanation = explanation + "\n" + std_streams
if use_cache:
cache_entry["merge status"] = MERGE_STATE.Merge_timedout.name
cache_entry["explanation"] = explanation
Expand All @@ -593,7 +598,7 @@ def merge(
-1,
)
run_time = time.time() - start_time
explanation = explanation + "\n" + stdout_and_stderr(command, p)
explanation = explanation + "\n" + std_streams
merge_status = (
MERGE_STATE.Merge_success if p.returncode == 0 else MERGE_STATE.Merge_failed
)
Expand Down
12 changes: 8 additions & 4 deletions src/scripts/merge_tools/merge_git_then_plumelib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,11 @@ fi

git config --local merge.tool merge-plumelib
# shellcheck disable=SC2016
git config --local mergetool.merge-plumelib.cmd 'merge-tool.sh '"$plumelib_strategy"' ${BASE} ${LOCAL} ${REMOTE} ${MERGED}'
if [ -n "$VERBOSE" ] ; then
git config --local mergetool.merge-plumelib.cmd 'merge-tool.sh --verbose '"$plumelib_strategy"' ${LOCAL} ${BASE} ${REMOTE} ${MERGED}'
else
git config --local mergetool.merge-plumelib.cmd 'merge-tool.sh '"$plumelib_strategy"' ${LOCAL} ${BASE} ${REMOTE} ${MERGED}'
fi
git config --local mergetool.merge-plumelib.trustExitCode true

case "$plumelib_strategy" in
Expand All @@ -76,11 +80,11 @@ esac
if [ -n "$VERBOSE" ] ; then
echo "$0: about to run: git-mergetool.sh $all_arg --tool=merge-plumelib in $(pwd)"
echo "$0: about to run: git-mergetool.sh $all_arg --tool=merge-plumelib in $(pwd)" >&2
fi
git-mergetool.sh $all_arg --tool=merge-plumelib
if [ -n "$VERBOSE" ] ; then
git-mergetool.sh --verbose $all_arg --tool=merge-plumelib
echo "$0: ran: git-mergetool.sh $all_arg --tool=merge-plumelib in $(pwd)"
echo "$0: ran: git-mergetool.sh $all_arg --tool=merge-plumelib in $(pwd)" >&2
else
git-mergetool.sh $all_arg --tool=merge-plumelib
fi

# Check if there are still conflicts
Expand Down
6 changes: 5 additions & 1 deletion src/scripts/merge_tools/merge_script_then_plumelib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,11 @@ fi

git config --local merge.tool merge-plumelib
# shellcheck disable=SC2016
git config --local mergetool.merge-plumelib.cmd 'merge-tool.sh '"$plumelib_strategy"' ${BASE} ${LOCAL} ${REMOTE} ${MERGED}'
if [ -n "$VERBOSE" ] ; then
git config --local mergetool.merge-plumelib.cmd 'merge-tool.sh --verbose '"$plumelib_strategy"' ${LOCAL} ${BASE} ${REMOTE} ${MERGED}'
else
git config --local mergetool.merge-plumelib.cmd 'merge-tool.sh '"$plumelib_strategy"' ${LOCAL} ${BASE} ${REMOTE} ${MERGED}'
fi
git config --local mergetool.merge-plumelib.trustExitCode true

case "$plumelib_strategy" in
Expand Down

0 comments on commit 22f829e

Please sign in to comment.