Skip to content

Commit

Permalink
[GR-54826] Mergetool should use the remote branch of a conflict marker
Browse files Browse the repository at this point in the history
PullRequest: mx/1814
  • Loading branch information
zapster committed Jul 2, 2024
2 parents bddf782 + 4b96d61 commit b76c871
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 17 deletions.
31 changes: 30 additions & 1 deletion ci.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,34 @@ local with(platform, java_release, timelimit="15:00") = {
],
},

mx_mergetool_gate:: self.with_name("gate-mergetool-tests") + {
local test_mergetool(repo, local_rev, remote_rev, reference_rev) = [
# git setup
["git", "-C", repo, "config", "user.name", "ol-automation_ww"],
["git", "-C", repo, "config", "user.email", "[email protected]"],
["git", "-C", repo, "config", "mergetool.mx-suite-import.cmd",
# use printf subcommand to work around environment variable substitution of $LOCAL, $BASE, etc. [GR-52812]
["printf", '${MX_HOME}/' + mx + ' -p ${MX_HOME} mergetool-suite-import "\\x24LOCAL" "\\x24BASE" "\\x24REMOTE" "\\x24MERGED"']
],
["git", "-C", repo, "config", "mergetool.mx-suite-import.trustExitCode", "true"],
# merging
["git", "-C", repo, "checkout", local_rev],
["git", "-C", repo, "merge", "--no-ff", "--no-commit", remote_rev, "||", "git", "-C", repo, "mergetool", "--tool", "mx-suite-import"],
["test", "-z", ["git", "-C", repo, "diff", reference_rev]],
],
local test_repo = "test_repo",
environment+: {
MERGETOOL_TEST_REPO: "<mergetool-test-repo>",
},
setup: [
["set-export", "MX_HOME", ["pwd"]],
["git", "clone", "${MERGETOOL_TEST_REPO}", test_repo],
],
run:
test_mergetool(test_repo, "caffcf0fe72", "172acf1141f", "ebf58d86069f5450adfe4a617aa3b52a9887a257")+ # GR-54826
test_mergetool(test_repo, "195c215f9cf", "a6862ad4f37", "8f54cbb8faed3a765069d81b4f075b923bf39533 "), # GR-54649
},

version_update_check:: self.with_name("version-update-check") + {
publishArtifacts: [
{
Expand Down Expand Up @@ -213,7 +241,7 @@ local with(platform, java_release, timelimit="15:00") = {
specVersion: "3",

# Overlay
overlay: "7fd31a78943e2a4d6e15573401b5865822980223",
overlay: "4c0f01b4995da0869a88a54863ca99a30f8e75d5",

# For use by overlay
versions:: versions,
Expand All @@ -234,6 +262,7 @@ local with(platform, java_release, timelimit="15:00") = {
with(common.linux_amd64, self.primary_jdk_version, timelimit="30:00").proftool_test,
with(common.linux_amd64, self.primary_jdk_version, timelimit="30:00").build_graalvm_ce,
with(common.linux_amd64, self.primary_jdk_version).mx_unit_test,
with(common.linux_amd64, self.primary_jdk_version).mx_mergetool_gate,
with(common.linux_amd64, self.primary_jdk_version).version_update_check,
with(common.linux_amd64, self.primary_jdk_version).post_merge_tag_version,

Expand Down
16 changes: 8 additions & 8 deletions common.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"Jsonnet files should not include this file directly but use ci/common.jsonnet instead."
],

"mx_version": "7.27.0",
"mx_version": "7.27.1",

"COMMENT.jdks": "When adding or removing JDKs keep in sync with JDKs in ci/common.jsonnet",
"jdks": {
Expand Down Expand Up @@ -45,13 +45,13 @@
"labsjdk-ee-21-llvm": {"name": "labsjdk", "version": "ee-21.0.2+13-jvmci-23.1-b33-sulong", "platformspecific": true },
"graalvm-ee-21": {"name": "graalvm-java21", "version": "23.1.3", "platformspecific": true },

"oraclejdk-latest": {"name": "jpg-jdk", "version": "24", "build_id": "jdk-24+2", "platformspecific": true, "extrabundles": ["static-libs"]},
"labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-24+2-jvmci-b01", "platformspecific": true },
"labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-24+2-jvmci-b01-debug", "platformspecific": true },
"labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-24+2-jvmci-b01-sulong", "platformspecific": true },
"labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-24+2-jvmci-b01", "platformspecific": true },
"labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-24+2-jvmci-b01-debug", "platformspecific": true },
"labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-24+2-jvmci-b01-sulong", "platformspecific": true }
"oraclejdk-latest": {"name": "jpg-jdk", "version": "24", "build_id": "jdk-24+3", "platformspecific": true, "extrabundles": ["static-libs"]},
"labsjdk-ce-latest": {"name": "labsjdk", "version": "ce-24+3-jvmci-b01", "platformspecific": true },
"labsjdk-ce-latestDebug": {"name": "labsjdk", "version": "ce-24+3-jvmci-b01-debug", "platformspecific": true },
"labsjdk-ce-latest-llvm": {"name": "labsjdk", "version": "ce-24+3-jvmci-b01-sulong", "platformspecific": true },
"labsjdk-ee-latest": {"name": "labsjdk", "version": "ee-24+3-jvmci-b01", "platformspecific": true },
"labsjdk-ee-latestDebug": {"name": "labsjdk", "version": "ee-24+3-jvmci-b01-debug", "platformspecific": true },
"labsjdk-ee-latest-llvm": {"name": "labsjdk", "version": "ee-24+3-jvmci-b01-sulong", "platformspecific": true }
},

"eclipse": {
Expand Down
14 changes: 7 additions & 7 deletions src/mx/_impl/mergetool.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

def remove_conflict_markers(filename):
"""
Removes conflicts markers from a file's content, keeps only the content of the first
Removes conflicts markers from a file's content, keeps only the content of the (last) remote
conflict branch and returns the result.
Merge conflict marker might be nested. A basic example looks like:
Expand Down Expand Up @@ -98,20 +98,20 @@ def remove_conflict_markers(filename):
keep = True
for line in suite_content.splitlines(keepends=True):
if line.startswith("<<"):
if conflict_level > 0:
# inner conflict scope -> stop printing
keep = False
# local branch -> stop printing
keep = False
conflict_level += 1
continue
if line.startswith("||"):
# in a conflict scope and not in the first branch -> stop printing
# base branch -> stop printing
keep = False
continue
if line.startswith("=="):
# in a conflict scope and not in the first branch -> stop printing
keep = False
# remote branch -> start printing if we are on the outer scope
keep = conflict_level <= 1
continue
if line.startswith(">>"):
# end of conflict marker
conflict_level -= 1
if conflict_level == 0:
# end of conflict scope -> restart printing
Expand Down
2 changes: 1 addition & 1 deletion src/mx/_impl/mx.py
Original file line number Diff line number Diff line change
Expand Up @@ -18195,7 +18195,7 @@ def alarm_handler(signum, frame):
_CACHE_DIR = get_env('MX_CACHE_DIR', join(dot_mx_dir(), 'cache'))

# The version must be updated for every PR (checked in CI) and the comment should reflect the PR's issue
version = VersionSpec("7.27.4") # GR-54950
version = VersionSpec("7.27.5") # mergetool conflict marker fix

_mx_start_datetime = datetime.utcnow()

Expand Down

0 comments on commit b76c871

Please sign in to comment.