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 23, 2024
2 parents 9716422 + 170cca7 commit 53b6eef
Show file tree
Hide file tree
Showing 67 changed files with 787 additions and 117 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ fix-java-style:
check-java-style:
./gradlew -q spotlessCheck javadoc requireJavadoc -g ../.gradle/

update-small-results:
rm -rf test/small-goal-files/
rsync -av --exclude='*.pdf' --exclude='*.png' --exclude='*unhandled_and_failed_merges_without_intellimerge*' --exclude='*.pgf' results/small/ test/small-goal-files/

# This target deletes files that are not committed to version control.
clean:
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,10 @@ 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`.
To update the reproducibility tests, run `make run-all`
(this takes a long time!) and commit the results.
This will run merges in parallel. If the load on your machine becomes very low
(like no parallelism is happening), then terminate the process and restart it.

### Load the stored cache

Expand Down Expand Up @@ -245,8 +248,7 @@ To investigate differences between two mergers:
* Run `src/python/utils/select_from_results.py` to create a .csv database containing only the differences.
* 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`.
If the merge is in the small test, you may need to add `--merges_csv ./test/small-goal-files/result.csv`.

## Overwriting results manually

Expand Down
20 changes: 14 additions & 6 deletions src/python/replay_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def merge_replay(
create_artifacts: bool = False,
dont_check_fingerprints: bool = False,
testing: bool = False,
verbose: bool = False,
) -> pd.DataFrame:
"""Replay a merge and its test results.
Args:
Expand Down Expand Up @@ -254,6 +255,7 @@ def merge_replay(
_,
) = repo.merge(
tool=merge_tool,
verbose=verbose,
left_commit=merge_data["left"],
right_commit=merge_data["right"],
timeout=TIMEOUT_MERGING,
Expand Down Expand Up @@ -406,6 +408,11 @@ def merge_replay(
type=str,
default="1-7",
)
parser.add_argument(
"--verbose",
help="Run verbosely, with diagnostic output",
action=argparse.BooleanOptionalAction,
)
parser.add_argument(
"-test",
help="Test the replay of a merge",
Expand Down Expand Up @@ -440,17 +447,17 @@ def merge_replay(

logger.info(f"Replaying merge with index {args.idx}")
if args.delete_workdir:
logger.info("Deleting workdir after replaying the merge")
logger.info(" Will delete workdir after replaying the merge")
if args.dont_check_fingerprints:
logger.info("Not checking the fingerprint of a merge")
logger.info(" Will not check the fingerprint of a merge")
if args.test:
logger.info("Testing the replay of a merge")
logger.info(" Will test the replay of a merge")
if args.create_artifacts:
logger.info("Creating artifacts after replaying the merges")
logger.info(" Will create artifacts after replaying the merges")
if not args.skip_build:
logger.info("Building merge tool")
logger.info(" Will build merge tool")
if args.testing:
logger.info("Checking for reproducibility")
logger.info(" Will check for reproducibility")

os.environ["PATH"] += os.pathsep + os.path.join(
os.getcwd(), "src/scripts/merge_tools/merging/src/main/sh/"
Expand All @@ -477,6 +484,7 @@ def merge_replay(
args.create_artifacts,
args.dont_check_fingerprints,
args.testing,
args.verbose,
)
for idx, row in results_df.iterrows():
logger.info("=====================================")
Expand Down
8 changes: 7 additions & 1 deletion src/python/repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,7 @@ def merge(
right_commit: str,
timeout: int,
use_cache: bool = True,
verbose: bool = False,
) -> Tuple[
MERGE_STATE, Union[str, None], Union[str, None], Union[str, None], str, float
]:
Expand Down Expand Up @@ -563,14 +564,19 @@ def merge(
f"merge: Merging {self.repo_slug} {left_commit} {right_commit} with {tool.name}"
)
start_time = time.time()

tool_sh = f"src/scripts/merge_tools/{tool.name}.sh"
if verbose:
tool_sh += " --verbose"
command = [
"src/scripts/run_with_timeout.sh",
str(timeout),
f"src/scripts/merge_tools/{tool.name}.sh {self.local_repo_path.resolve()} {LEFT_BRANCH_NAME} {RIGHT_BRANCH_NAME}",
f"{tool_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}"
)
logger.debug(f"command = {command}")
p = subprocess.run(
command,
capture_output=True,
Expand Down
1 change: 1 addition & 0 deletions src/python/utils/select_from_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

"""Output a subset of the results, to standard out.
The arguments are a query and an optional list of columns.
It is also permitted to pass "--input CSV_FILENAME".
The query is executed (to select rows), then columns are output that include:
* idx
* all the columns that appear in the query
Expand Down
12 changes: 10 additions & 2 deletions src/scripts/merge_tools/adjacent.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
#!/usr/bin/env sh

# usage: <scriptname> <clone_dir> <branch-1> <branch-2>
# usage: <scriptname> [--verbose] <clone_dir> <branch-1> <branch-2>

MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)"

verbose=
if [ "$1" = "--verbose" ] ; then
verbose="$1"
shift
fi

clone_dir=$1
branch1=$2
branch2=$3
git_strategy="-s ort"
plumelib_strategy="--only-adjacent"
"$MERGE_SCRIPTS_DIR"/merge_git_then_plumelib.sh "$clone_dir" "$branch1" "$branch2" "$git_strategy" "$plumelib_strategy"
# shellcheck disable=SC2086 # '$verbose' should not be quoted
"$MERGE_SCRIPTS_DIR"/merge_git_then_plumelib.sh $verbose "$clone_dir" "$branch1" "$branch2" "$git_strategy" "$plumelib_strategy"
12 changes: 10 additions & 2 deletions src/scripts/merge_tools/adjacent_ignorespace.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
#!/usr/bin/env sh

# usage: <scriptname> <clone_dir> <branch-1> <branch-2>
# usage: <scriptname> [--verbose] <clone_dir> <branch-1> <branch-2>

MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)"

verbose=
if [ "$1" = "--verbose" ] ; then
verbose="$1"
shift
fi

clone_dir=$1
branch1=$2
branch2=$3
git_strategy="-s ort -Xignore-space-change"
plumelib_strategy="--only-adjacent"
"$MERGE_SCRIPTS_DIR"/merge_git_then_plumelib.sh "$clone_dir" "$branch1" "$branch2" "$git_strategy" "$plumelib_strategy"
# shellcheck disable=SC2086 # '$verbose' should not be quoted
"$MERGE_SCRIPTS_DIR"/merge_git_then_plumelib.sh $verbose "$clone_dir" "$branch1" "$branch2" "$git_strategy" "$plumelib_strategy"
12 changes: 10 additions & 2 deletions src/scripts/merge_tools/adjacent_ignorespace_plus.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
#!/usr/bin/env sh

# usage: <scriptname> <clone_dir> <branch-1> <branch-2>
# usage: <scriptname> [--verbose] <clone_dir> <branch-1> <branch-2>

MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)"

verbose=
if [ "$1" = "--verbose" ] ; then
verbose="$1"
shift
fi

clone_dir=$1
branch1=$2
branch2=$3
git_strategy="-s ort -Xignore-space-change"
plumelib_strategy="--adjacent"
"$MERGE_SCRIPTS_DIR"/merge_git_then_plumelib.sh "$clone_dir" "$branch1" "$branch2" "$git_strategy" "$plumelib_strategy"
# shellcheck disable=SC2086 # '$verbose' should not be quoted
"$MERGE_SCRIPTS_DIR"/merge_git_then_plumelib.sh $verbose "$clone_dir" "$branch1" "$branch2" "$git_strategy" "$plumelib_strategy"
12 changes: 10 additions & 2 deletions src/scripts/merge_tools/adjacent_plus.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
#!/usr/bin/env sh

# usage: <scriptname> <clone_dir> <branch-1> <branch-2>
# usage: <scriptname> [--verbose] <clone_dir> <branch-1> <branch-2>

MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)"

verbose=
if [ "$1" = "--verbose" ] ; then
verbose="$1"
shift
fi

clone_dir=$1
branch1=$2
branch2=$3
git_strategy="-s ort"
plumelib_strategy="--adjacent"
"$MERGE_SCRIPTS_DIR"/merge_git_then_plumelib.sh "$clone_dir" "$branch1" "$branch2" "$git_strategy" "$plumelib_strategy"
# shellcheck disable=SC2086 # '$verbose' should not be quoted
"$MERGE_SCRIPTS_DIR"/merge_git_then_plumelib.sh $verbose "$clone_dir" "$branch1" "$branch2" "$git_strategy" "$plumelib_strategy"
8 changes: 6 additions & 2 deletions src/scripts/merge_tools/git_hires_merge.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
#!/usr/bin/env sh

# usage: <scriptname> <clone_dir> <branch-1> <branch-2>
# usage: <scriptname> [--verbose] <clone_dir> <branch-1> <branch-2>

set -o nounset

if [ "$1" = "--verbose" ] ; then
shift
fi

if [ "$#" -ne 3 ]; then
echo "Usage: $0 CLONE_DIR BRANCH1 BRANCH2" >&2
echo "Usage: $0 [--verbose] CLONE_DIR BRANCH1 BRANCH2" >&2
exit 1
fi

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

# usage: <scriptname> <clone_dir> <branch-1> <branch-2>
# usage: <scriptname> [--verbose] <clone_dir> <branch-1> <branch-2>

MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)"

if [ "$1" = "--verbose" ] ; then
shift
fi

clone_dir=$1
branch1=$2
branch2=$3
Expand Down
7 changes: 6 additions & 1 deletion src/scripts/merge_tools/gitmerge_ort.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
#!/usr/bin/env sh

# usage: <scriptname> <clone_dir> <branch-1> <branch-2>
# usage: <scriptname> [--verbose] <clone_dir> <branch-1> <branch-2>

MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)"

if [ "$1" = "--verbose" ] ; then
shift
fi

clone_dir=$1
branch1=$2
branch2=$3
Expand Down
7 changes: 6 additions & 1 deletion src/scripts/merge_tools/gitmerge_ort_ignorespace.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
#!/usr/bin/env sh

# usage: <scriptname> <clone_dir> <branch-1> <branch-2>
# usage: <scriptname> [--verbose] <clone_dir> <branch-1> <branch-2>

MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)"

if [ "$1" = "--verbose" ] ; then
shift
fi

clone_dir=$1
branch1=$2
branch2=$3
Expand Down
12 changes: 10 additions & 2 deletions src/scripts/merge_tools/gitmerge_ort_ignorespace_plus.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
#!/usr/bin/env sh

# usage: <scriptname> <clone_dir> <branch-1> <branch-2>
# usage: <scriptname> [--verbose] <clone_dir> <branch-1> <branch-2>

MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)"

verbose=
if [ "$1" = "--verbose" ] ; then
verbose="$1"
shift
fi

clone_dir=$1
branch1=$2
branch2=$3
git_strategy="-s ort -Xignore-space-change"
plumelib_strategy=""
"$MERGE_SCRIPTS_DIR"/merge_git_then_plumelib.sh "$clone_dir" "$branch1" "$branch2" "$git_strategy" "$plumelib_strategy"
# shellcheck disable=SC2086 # '$verbose' should not be quoted
"$MERGE_SCRIPTS_DIR"/merge_git_then_plumelib.sh $verbose "$clone_dir" "$branch1" "$branch2" "$git_strategy" "$plumelib_strategy"
12 changes: 10 additions & 2 deletions src/scripts/merge_tools/gitmerge_ort_plus.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
#!/usr/bin/env sh

# usage: <scriptname> <clone_dir> <branch-1> <branch-2>
# usage: <scriptname> [--verbose] <clone_dir> <branch-1> <branch-2>

MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)"

verbose=
if [ "$1" = "--verbose" ] ; then
verbose="$1"
shift
fi

clone_dir=$1
branch1=$2
branch2=$3
git_strategy="-s ort"
plumelib_strategy=""
"$MERGE_SCRIPTS_DIR"/merge_git_then_plumelib.sh "$clone_dir" "$branch1" "$branch2" "$git_strategy" "$plumelib_strategy"
# shellcheck disable=SC2086 # '$verbose' should not be quoted
"$MERGE_SCRIPTS_DIR"/merge_git_then_plumelib.sh $verbose "$clone_dir" "$branch1" "$branch2" "$git_strategy" "$plumelib_strategy"
7 changes: 6 additions & 1 deletion src/scripts/merge_tools/gitmerge_recursive_histogram.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
#!/usr/bin/env sh

# usage: <scriptname> <clone_dir> <branch-1> <branch-2>
# usage: <scriptname> [--verbose] <clone_dir> <branch-1> <branch-2>

MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)"

if [ "$1" = "--verbose" ] ; then
shift
fi

clone_dir=$1
branch1=$2
branch2=$3
Expand Down
12 changes: 10 additions & 2 deletions src/scripts/merge_tools/gitmerge_recursive_histogram_plus.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
#!/usr/bin/env sh

# usage: <scriptname> <clone_dir> <branch-1> <branch-2>
# usage: <scriptname> [--verbose] <clone_dir> <branch-1> <branch-2>

MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)"

verbose=
if [ "$1" = "--verbose" ] ; then
verbose="$1"
shift
fi

clone_dir=$1
branch1=$2
branch2=$3
git_strategy="-s recursive -Xdiff-algorithm=histogram"
plumelib_strategy=""
"$MERGE_SCRIPTS_DIR"/merge_git_then_plumelib.sh "$clone_dir" "$branch1" "$branch2" "$git_strategy" "$plumelib_strategy"
# shellcheck disable=SC2086 # '$verbose' should not be quoted
"$MERGE_SCRIPTS_DIR"/merge_git_then_plumelib.sh $verbose "$clone_dir" "$branch1" "$branch2" "$git_strategy" "$plumelib_strategy"
7 changes: 6 additions & 1 deletion src/scripts/merge_tools/gitmerge_recursive_minimal.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
#!/usr/bin/env sh

# usage: <scriptname> <clone_dir> <branch-1> <branch-2>
# usage: <scriptname> [--verbose] <clone_dir> <branch-1> <branch-2>

MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)"

if [ "$1" = "--verbose" ] ; then
shift
fi

clone_dir=$1
branch1=$2
branch2=$3
Expand Down
12 changes: 10 additions & 2 deletions src/scripts/merge_tools/gitmerge_recursive_minimal_plus.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
#!/usr/bin/env sh

# usage: <scriptname> <clone_dir> <branch-1> <branch-2>
# usage: <scriptname> [--verbose] <clone_dir> <branch-1> <branch-2>

MERGE_SCRIPTS_DIR="$(cd "$(dirname "$0")" && pwd -P)"

verbose=
if [ "$1" = "--verbose" ] ; then
verbose="$1"
shift
fi

clone_dir=$1
branch1=$2
branch2=$3
git_strategy="-s recursive -Xdiff-algorithm=minimal"
plumelib_strategy=""
"$MERGE_SCRIPTS_DIR"/merge_git_then_plumelib.sh "$clone_dir" "$branch1" "$branch2" "$git_strategy" "$plumelib_strategy"
# shellcheck disable=SC2086 # '$verbose' should not be quoted
"$MERGE_SCRIPTS_DIR"/merge_git_then_plumelib.sh $verbose "$clone_dir" "$branch1" "$branch2" "$git_strategy" "$plumelib_strategy"
Loading

0 comments on commit 53b6eef

Please sign in to comment.