Skip to content

Commit

Permalink
Merge branch 'main' into app-pre4
Browse files Browse the repository at this point in the history
  • Loading branch information
benedikt-schesch authored Sep 21, 2024
2 parents 9133066 + 26bb427 commit 6ee17d9
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 10 deletions.
2 changes: 1 addition & 1 deletion run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ fi
cd ./src/scripts/merge_tools/merging
export JAVA_HOME=$GRAALVM_HOME
export PATH="$JAVA_HOME/bin:$PATH"
./gradlew nativeCompile
./gradlew -q nativeCompile
)

echo "Machine ID: $machine_id"
Expand Down
7 changes: 4 additions & 3 deletions src/python/replay_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ def merge_replay(
is_conflict = len(git_conflict_files) > 0
assert (
is_conflict == (merge_result == MERGE_STATE.Merge_failed)
), f"merge_replay: tool{merge_tool} merge_result {merge_result} does not match git_conflict_files {git_conflict_files} at path {repo.local_repo_path}"
), f"merge_replay: tool merge result is inconsistent with `git diff --diff-filter=U`: tool={merge_tool} merge_result={merge_result} git_conflict_files={git_conflict_files} path={repo.local_repo_path}"

result_df.loc[
merge_tool.name,
Expand Down Expand Up @@ -308,10 +308,11 @@ def merge_replay(
store_artifacts(result_df)
if delete_workdir:
delete_workdirs(result_df)
print("=====================================\n")
print("fingerprints differ; details follow.")
print(f"=================== start of {log_path}:")
with open(log_path, "r", encoding="utf-8") as f:
print(f.read())
print("=====================================\n")
print(f"=================== end of {log_path}.")
raise Exception(
f"fingerprints differ: after merge of {workdir} with {merge_tool}, found"
+ f" {merge_fingerprint} but expected "
Expand Down
15 changes: 12 additions & 3 deletions src/python/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,20 @@ def stdout_and_stderr(
source: Union[subprocess.TimeoutExpired, subprocess.CompletedProcess],
) -> str:
"""Produces the standard output and standard error of a timedout process."""
explanation = "Run Command: " + " ".join(command) + "\nTimed out"
explanation = "Here is the output from: " + " ".join(command)
if source.stdout:
explanation += "\nstdout:\n" + source.stdout.decode("utf-8", "replace")
explanation += (
"\nstdout:\n"
+ source.stdout.decode("utf-8", "replace")
+ "\nEnd of stdout."
)
if source.stderr:
explanation += "\nstderr:\n" + source.stderr.decode("utf-8", "replace")
explanation += (
"\nstderr:\n"
+ source.stderr.decode("utf-8", "replace")
+ "\nEnd of stderr."
)
explanation += "\nEnd of output from: " + " ".join(command)
return explanation


Expand Down
18 changes: 17 additions & 1 deletion src/scripts/merge_tools/gitmerge.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,35 @@ branch1=$2
branch2=$3
git_strategy=$4

VERBOSE=
## Enable for debugging
# VERBOSE=YES


## Perform merge

cd "$clone_dir" || { echo "$0: cannot cd to $clone_dir"; exit 2; }

if [ -n "$VERBOSE" ] ; then
echo "$0: about to run: git checkout $branch1 in $(pwd)"
fi
git checkout "$branch1" --force
if [ -n "$VERBOSE" ] ; then
echo "$0: ran: git checkout $branch1 in $(pwd)"
fi
git config --local merge.conflictstyle diff3
git config --local mergetool.prompt false

echo "Running: git merge --no-edit $git_strategy $branch2"
echo "$0: about to run: git merge --no-edit $git_strategy $branch2 in $(pwd)"

# shellcheck disable=SC2086
git merge --no-edit $git_strategy "$branch2"
retVal=$?

if [ -n "$VERBOSE" ] ; then
echo "$0: ran: git merge --no-edit $git_strategy $branch2 in $(pwd)"
fi

# report conflicts
if [ $retVal -ne 0 ]; then
echo "gitmerge.sh: Conflict after running: git merge --no-edit $git_strategy $branch2"
Expand Down
34 changes: 33 additions & 1 deletion src/scripts/merge_tools/merge_git_then_plumelib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,38 @@ branch2=$3
git_strategy=$4 #"-Xignore-space-change"
plumelib_strategy=$5 #"--only-adjacent"

VERBOSE=
## Enable for debugging
# VERBOSE=YES


## Perform merge

echo "$0: Merging $branch1 and $branch2 with git_strategy=$git_strategy and plumelib_strategy=$plumelib_strategy"

cd "$clone_dir" || { echo "$0: cannot cd to $clone_dir"; exit 2; }

if [ -n "$VERBOSE" ] ; then
echo "$0: about to run: git checkout $branch1 in $(pwd)"
fi
git checkout "$branch1" --force
if [ -n "$VERBOSE" ] ; then
echo "$0: ran: git checkout $branch1 in $(pwd)"
fi
git config --local merge.conflictstyle diff3
git config --local mergetool.prompt false

if [ -n "$VERBOSE" ] ; then
echo "$0: about to run: git merge --no-edit $git_strategy $branch2 in $(pwd)"
fi

# shellcheck disable=SC2086
git merge --no-edit $git_strategy "$branch2"

if [ -n "$VERBOSE" ] ; then
echo "$0: ran: git merge --no-edit $git_strategy $branch2 in $(pwd)"
fi

## Now, run Plume-lib Merging to improve the result of `git merge`.

git config --local merge.tool merge-plumelib
Expand All @@ -50,15 +69,28 @@ case "$plumelib_strategy" in
;;
esac

if [ -n "$VERBOSE" ] ; then
echo "$0: about to run: git-mergetool.sh $all_arg --tool=merge-plumelib in $(pwd)"
fi
git-mergetool.sh $all_arg --tool=merge-plumelib
if [ -n "$VERBOSE" ] ; then
echo "$0: ran: git-mergetool.sh $all_arg --tool=merge-plumelib in $(pwd)"
fi

# Check if there are still conflicts
diffs=$(git diff --name-only --diff-filter=U)
diffs=$(git diff --name-only --diff-filter=U | sort)
if [ -z "$diffs" ]; then
git add .
if [ -n "$VERBOSE" ] ; then
echo "$0: about to run: git commit in $(pwd)"
fi
git commit -m "Resolved conflicts by calling: git-mergetool.sh $all_arg --tool=merge-plumelib"
if [ -n "$VERBOSE" ] ; then
echo "$0: ran: git commit in $(pwd)"
fi
exit 0
fi
echo "$0: exiting with status 1"
echo "$0: diffs=$diffs"
echo "$0: Conflict after running in $(pwd):"
echo " git merge --no-edit $git_strategy $branch2"
Expand Down
34 changes: 33 additions & 1 deletion src/scripts/merge_tools/merge_script_then_plumelib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,38 @@ branch2=$3
merge_script=$4 #"-Xignore-space-change"
plumelib_strategy=$5 #"--only-adjacent"

VERBOSE=
## Enable for debugging
# VERBOSE=YES


## Perform merge

echo "$0: Merging $branch1 and $branch2 with merge_script=$merge_script and plumelib_strategy=$plumelib_strategy"

cd "$clone_dir" || { echo "$0: cannot cd to $clone_dir"; exit 2; }

if [ -n "$VERBOSE" ] ; then
echo "$0: about to run: git checkout $branch1 in $(pwd)"
fi
git checkout "$branch1" --force
if [ -n "$VERBOSE" ] ; then
echo "$0: ran: git checkout $branch1 in $(pwd)"
fi
git config --local merge.conflictstyle diff3
git config --local mergetool.prompt false

if [ -n "$VERBOSE" ] ; then
echo "$0: about to run: $merge_script $clone_dir $branch1 $branch2 in $(pwd)"
fi

# shellcheck disable=SC2086
$merge_script "$clone_dir" "$branch1" "$branch2"

if [ -n "$VERBOSE" ] ; then
echo "$0: ran: $merge_script $clone_dir $branch1 $branch2 in $(pwd)"
fi

## Now, run Plume-lib Merging to improve the result of `$merge_script`.

git config --local merge.tool merge-plumelib
Expand All @@ -51,15 +70,28 @@ case "$plumelib_strategy" in
;;
esac

if [ -n "$VERBOSE" ] ; then
echo "$0: about to run: git-mergetool.sh $all_arg --tool=merge-plumelib in $(pwd)"
fi
git-mergetool.sh $all_arg --tool=merge-plumelib
if [ -n "$VERBOSE" ] ; then
echo "$0: ran: git-mergetool.sh $all_arg --tool=merge-plumelib in $(pwd)"
fi

# Check if there are still conflicts
diffs=$(git diff --name-only --diff-filter=U)
diffs=$(git diff --name-only --diff-filter=U | sort)
if [ -z "$diffs" ]; then
git add .
if [ -n "$VERBOSE" ] ; then
echo "$0: about to run: git commit in $(pwd)"
fi
git commit -m "Resolved conflicts by calling: git-mergetool.sh $all_arg --tool=merge-plumelib"
if [ -n "$VERBOSE" ] ; then
echo "$0: ran: git commit in $(pwd)"
fi
exit 0
fi
echo "$0: exiting with status 1"
echo "$0: diffs=$diffs"
echo "$0: Conflict after running in $(pwd):"
echo " $merge_script $clone_dir $branch1 $branch2"
Expand Down

0 comments on commit 6ee17d9

Please sign in to comment.