Skip to content

Commit

Permalink
Merge ../AST-Merging-Evaluation-branch-main into app-pre7
Browse files Browse the repository at this point in the history
  • Loading branch information
mernst committed Sep 22, 2024
2 parents c854fa8 + cd2cfe8 commit fa73dc1
Show file tree
Hide file tree
Showing 35 changed files with 108 additions and 43 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,14 @@ If `make small-test` fails in a branch that you wish to merge into the main
branch, run `make small-test` in the main branch (which should succeed) and also
in your branch, and investigate the differences.

#### Updating the goal files

If you make a change to the mergers that changes merge results, you need to
update the goal files or else reproducibility checks will fail.
Copy certain files from `results/small/` to `test/small-goal-files/`.

To update the reproducibility tests, run `make run-all`.

### Load the stored cache

To decompress the cache run `make decompress-cache`. This is done automatically in `run_combined.sh` if `cache/` does not exist.
Expand Down Expand Up @@ -238,6 +246,8 @@ To investigate differences between two mergers:
* Set `DELETE_WORKDIRS` to `false` in `src/python/variables.py`.
* run `src/python/replay_merge.py --idx INDEX` (maybe add `-test`) for the index of the merge you are interested in.

If the merge is in the small test, you may need to add `--merges_csv ./test/small-goal-files/result.csv`.

## Overwriting results manually

In some cases it might be worth to overwrite the computed results. To do that you should modify the `results/manual_override.csv` file. In that file for the merge you want to overwrite a result of you should include at least the information `repository,merge,left,right` and a new column for the result you want to overwrite. You can overwrite anything you want but if there is a column you don't want to overwrite either do not include that column or leave the entry blanck i.e. `,,`. See the file for an example.
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
11 changes: 6 additions & 5 deletions src/python/replay_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,11 @@ def merge_replay(
stderr=subprocess.PIPE,
)
if len(process.stderr.decode("utf-8")) == 0:
conflict_files = process.stdout.decode("utf-8")
is_conflict = len(conflict_files) > 0
git_conflict_files = process.stdout.decode("utf-8")
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 conflict_files {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
2 changes: 1 addition & 1 deletion src/scripts/merge_tools/adjacent.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env sh

# usage: ./adjacent.sh <clone_dir> <branch-1> <branch-2>
# usage: <scriptname> <clone_dir> <branch-1> <branch-2>

MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)"
clone_dir=$1
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/merge_tools/adjacent_ignorespace.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env sh

# usage: ./adjacent_ignorespace.sh <clone_dir> <branch-1> <branch-2>
# usage: <scriptname> <clone_dir> <branch-1> <branch-2>

MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)"
clone_dir=$1
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/merge_tools/adjacent_plus.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env sh

# usage: ./adjacent.sh <clone_dir> <branch-1> <branch-2>
# usage: <scriptname> <clone_dir> <branch-1> <branch-2>

MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)"
clone_dir=$1
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/merge_tools/git_hires_merge.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env sh

# usage: ./git_hires_merge.sh <clone_dir> <branch-1> <branch-2>
# usage: <scriptname> <clone_dir> <branch-1> <branch-2>

set -o nounset

Expand Down
2 changes: 1 addition & 1 deletion src/scripts/merge_tools/git_hires_merge_plus.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env sh

# usage: ./git_hires_merge_plus.sh <clone_dir> <branch-1> <branch-2>
# usage: <scriptname> <clone_dir> <branch-1> <branch-2>

MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)"
clone_dir=$1
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/merge_tools/gitmerge_ort.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env sh

# usage: ./gitmerge_ort.sh <clone_dir> <branch-1> <branch-2>
# usage: <scriptname> <clone_dir> <branch-1> <branch-2>

MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)"
clone_dir=$1
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/merge_tools/gitmerge_ort_ignorespace.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env sh

# usage: ./gitmerge_ort_ignorespace.sh <clone_dir> <branch-1> <branch-2>
# usage: <scriptname> <clone_dir> <branch-1> <branch-2>

MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)"
clone_dir=$1
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/merge_tools/gitmerge_recursive_histogram.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env sh

# usage: ./gitmerge_recursive_histogram.sh <clone_dir> <branch-1> <branch-2>
# usage: <scriptname> <clone_dir> <branch-1> <branch-2>

MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)"
clone_dir=$1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env sh

# usage: ./gitmerge_recursive_histogram_plus.sh <clone_dir> <branch-1> <branch-2>
# usage: <scriptname> <clone_dir> <branch-1> <branch-2>

MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)"
clone_dir=$1
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/merge_tools/gitmerge_recursive_ignorespace.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env sh

# usage: ./gitmerge_recursive_ignorespace.sh <clone_dir> <branch-1> <branch-2>
# usage: <scriptname> <clone_dir> <branch-1> <branch-2>

MERGE_DIR="$(dirname "$0")"
clone_dir=$1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env sh

# usage: ./gitmerge_recursive_ignorespace_plus.sh <clone_dir> <branch-1> <branch-2>
# usage: <scriptname> <clone_dir> <branch-1> <branch-2>

MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)"
clone_dir=$1
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/merge_tools/gitmerge_recursive_minimal.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env sh

# usage: ./gitmerge_recursive_minimal.sh <clone_dir> <branch-1> <branch-2>
# usage: <scriptname> <clone_dir> <branch-1> <branch-2>

MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)"
clone_dir=$1
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/merge_tools/gitmerge_recursive_minimal_plus.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env sh

# usage: ./gitmerge_recursive_minimal_plus.sh <clone_dir> <branch-1> <branch-2>
# usage: <scriptname> <clone_dir> <branch-1> <branch-2>

MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)"
clone_dir=$1
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/merge_tools/gitmerge_recursive_myers.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env sh

# usage: ./gitmerge_recursive_myers.sh <clone_dir> <branch-1> <branch-2>
# usage: <scriptname> <clone_dir> <branch-1> <branch-2>

MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)"
clone_dir=$1
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/merge_tools/gitmerge_recursive_myers_plus.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env sh

# usage: ./gitmerge_recursive_myers_plus.sh <clone_dir> <branch-1> <branch-2>
# usage: <scriptname> <clone_dir> <branch-1> <branch-2>

MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)"
clone_dir=$1
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/merge_tools/gitmerge_recursive_patience.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env sh

# usage: ./gitmerge_recursive_patience.sh <clone_dir> <branch-1> <branch-2>
# usage: <scriptname> <clone_dir> <branch-1> <branch-2>

MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)"
clone_dir=$1
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env sh

# usage: ./gitmerge_recursive_patience_plus.sh <clone_dir> <branch-1> <branch-2>
# usage: <scriptname> <clone_dir> <branch-1> <branch-2>

MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)"
clone_dir=$1
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/merge_tools/gitmerge_resolve.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

# usage: ./gitmerge_resolve.sh <clone_dir> <branch-1> <branch-2>
# usage: <scriptname> <clone_dir> <branch-1> <branch-2>

MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)"
clone_dir=$1
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/merge_tools/gitmerge_resolve_plus.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env sh

# usage: ./gitmerge_resolve_plus.sh <clone_dir> <branch-1> <branch-2>
# usage: <scriptname> <clone_dir> <branch-1> <branch-2>

MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)"
clone_dir=$1
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/merge_tools/imports.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env sh

# usage: ./imports.sh <clone_dir> <branch-1> <branch-2>
# usage: <scriptname> <clone_dir> <branch-1> <branch-2>

MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)"
clone_dir=$1
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/merge_tools/imports_ignorespace.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env sh

# usage: ./imports_ignorespace.sh <clone_dir> <branch-1> <branch-2>
# usage: <scriptname> <clone_dir> <branch-1> <branch-2>

MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)"
clone_dir=$1
Expand Down
8 changes: 4 additions & 4 deletions src/scripts/merge_tools/intellimerge.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env sh

# usage: ./intellimerge.sh <clone_dir> <branch-1> <branch-2>
# usage: <scriptname> <clone_dir> <branch-1> <branch-2>
# <clone_dir> must contain a clone of a repository.
# Merges branch2 into branch1, in <clone_dir>.
# Return code is 0 for merge success, 1 for merge failure, 2 for script failure.
Expand Down Expand Up @@ -44,13 +44,13 @@ git checkout "$branch1" --force
git merge --no-edit "$branch2"

# List conflicitng files
conflict_files=$(git diff --name-only --diff-filter=U)
git_conflict_files=$(git diff --name-only --diff-filter=U)

# Initialize a flag to track conflict resolution
conflicts_resolved=true

# Iterate through conflicting files
for file in $conflict_files; do
for file in $git_conflict_files; do
# Check if the conflicting file exists in the temp_out_dir
if [ ! -f "$temp_out_dir$file" ]; then
echo "Conflict not resolved for file: $file"
Expand All @@ -62,7 +62,7 @@ done
if [ "$conflicts_resolved" = false ]; then
echo "Conflict detected. Aborting the merge. Please resolve the conflicts."
echo "All conflicting files:"
echo "$conflict_files"
echo "$git_conflict_files"
rm -rf $temp_out_dir $temp_intellimerge_dir
exit 1
fi
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/merge_tools/intellimerge_plus.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env sh

# usage: ./intellimerge_plus.sh <clone_dir> <branch-1> <branch-2>
# usage: <scriptname> <clone_dir> <branch-1> <branch-2>

MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)"
clone_dir=$1
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/merge_tools/ivn.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env sh

# usage: ./ivn.sh <clone_dir> <branch-1> <branch-2>
# usage: <scriptname> <clone_dir> <branch-1> <branch-2>

MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)"
clone_dir=$1
Expand Down
2 changes: 1 addition & 1 deletion src/scripts/merge_tools/ivn_ignorespace.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env sh

# usage: ./ivn_ignorespace.sh <clone_dir> <branch-1> <branch-2>
# usage: <scriptname> <clone_dir> <branch-1> <branch-2>

MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)"
clone_dir=$1
Expand Down
15 changes: 14 additions & 1 deletion src/scripts/merge_tools/merge_git_then_plumelib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,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
Loading

0 comments on commit fa73dc1

Please sign in to comment.