Skip to content

Commit

Permalink
Update git-hires-merge from upstream (#315)
Browse files Browse the repository at this point in the history
  • Loading branch information
mernst authored Jul 11, 2024
1 parent 18e99be commit e2f9c78
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ style: shell-script-style python-style java-style

SH_SCRIPTS = $(shell grep --exclude-dir=build --exclude-dir=repos --exclude-dir=cache -r -l '^\#! \?\(/bin/\|/usr/bin/env \)sh' * | grep -v 'git-hires-merge' | grep -v /.git/ | grep -v '~$$' | grep -v '\.tar$$' | grep -v gradlew)
BASH_SCRIPTS = $(shell grep --exclude-dir=build --exclude-dir=repos --exclude-dir=cache -r -l '^\#! \?\(/bin/\|/usr/bin/env \)bash' * | grep -v /.git/ | grep -v '~$$' | grep -v '\.tar$$' | grep -v gradlew)
PYTHON_FILES = $(shell find . -name '*.py' ! -path './repos/*' -not -path "./.workdir/*" -not -path "./cache*/*" | grep -v '/__pycache__/' | grep -v '/.git/' | grep -v gradlew)
PYTHON_FILES = $(shell find . -name '*.py' ! -path './repos/*' -not -path "./.workdir/*" -not -path "./cache*/*" | grep -v '/__pycache__/' | grep -v '/.git/' | grep -v gradlew | grep -v git-hires-merge)

CSV_RESULTS_COMBINED = results/combined/result.csv
CSV_RESULTS_GREATEST_HITS = results/greatest_hits/result.csv
Expand Down
2 changes: 1 addition & 1 deletion src/python/merge_runtime_measure.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def main():
else:
logger.info(
f"merge_timer: Running {merge_tool.name} "
f"on {idx} {repo_slug} {left_hash} {right_hash}"
f"on {merge_idx} {repo_slug} {left_hash} {right_hash}"
)
run_times = []
for _ in range(args.n_timings):
Expand Down
4 changes: 2 additions & 2 deletions src/python/replay_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,8 @@ def merge_replay(
if len(process.stderr.decode("utf-8")) == 0:
conflict_files = process.stdout.decode("utf-8")
is_conflict = len(conflict_files) > 0
assert is_conflict == (
merge_result == MERGE_STATE.Merge_failed
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}"

result_df.loc[
Expand Down
2 changes: 0 additions & 2 deletions src/python/utils/delete_import_keys_from_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
"""Delete the keys containing 'imports' in the JSON files in the given directory."""

import os
import sys
import json
from pathlib import Path
from argparse import ArgumentParser


def count_import_keys(directory: Path) -> int:
Expand Down
22 changes: 16 additions & 6 deletions src/scripts/merge_tools/git-hires-merge
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,20 @@ try:
except ImportError:
pass

# for interpreting environment variables
try:
from distutils.util import strtobool
except ImportError:
from distutils import strtobool
# copied from distutils to avoid deprecation warning on python 3.11 and removal on 3.12 and onwards
def strtobool (val):
"""Convert a string representation of truth to true (1) or false (0).
True values are 'y', 'yes', 't', 'true', 'on', and '1'; false values
are 'n', 'no', 'f', 'false', 'off', and '0'. Raises ValueError if
'val' is anything else.
"""
val = val.lower()
if val in ('y', 'yes', 't', 'true', 'on', '1'):
return 1
elif val in ('n', 'no', 'f', 'false', 'off', '0'):
return 0
else:
raise ValueError("invalid truth value %r" % (val,))


#############
Expand Down Expand Up @@ -791,7 +800,7 @@ for line in tmp:
# beginning of conflict zone
if line.startswith(marker_start):
zone = 1
for f in hunk:
for f in hunk:
f.truncate(0)
f.seek(0)

Expand Down Expand Up @@ -827,3 +836,4 @@ print(col + color.bold + newline + 'Resolved %d of %d conflicts in %s' % (resolv

# only exit with success if all conflicts were resolved
sys.exit(0 if resolved == num_conflicts else 1)

0 comments on commit e2f9c78

Please sign in to comment.