Skip to content

Commit fdf8362

Browse files
committed
avoid the FS churn of checking out revisions, instead just show the suite.py we need
1 parent fffbbab commit fdf8362

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

mx.graalpython/mx_graalpython.py

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1421,38 +1421,39 @@ def checkout_find_version_for_graalvm(args):
14211421
path = args[0]
14221422
projectname = os.path.basename(args[0])
14231423
suite = os.path.join(path, "mx.%s" % projectname, "suite.py")
1424+
basedir = os.path.dirname(suite)
1425+
while not os.path.isdir(os.path.join(basedir, ".git")):
1426+
basedir = os.path.dirname(basedir)
1427+
suite = os.path.relpath(suite, start=basedir)
1428+
mx.log("Using %s to find revision" % suite)
14241429
other_version = ""
14251430
for i in SUITE.suite_imports:
14261431
if i.name == "sulong":
14271432
needed_version = i.version
14281433
break
14291434
current_commit = SUITE.vc.tip(path).strip()
1435+
current_revision = "HEAD"
14301436
mx.log("Searching %s commit that imports graal repository at %s" % (projectname, needed_version))
14311437
while needed_version != other_version:
14321438
if other_version:
1433-
parent = SUITE.vc.git_command(path, ["show", "--pretty=format:%P", "-s", "HEAD"]).split()
1439+
parent = SUITE.vc.git_command(path, ["show", "--pretty=format:%P", "-s", current_revision]).split()
14341440
if not parent:
1435-
mx.log("Got to oldest revision before finding appropriate commit, reverting to %s" % current_commit)
1436-
SUITE.vc.update(path, rev=current_commit)
1441+
mx.log("Got to oldest revision before finding appropriate commit, using %s" % current_commit)
14371442
return
1438-
parent = parent[0]
1439-
SUITE.vc.update(path, rev=parent)
1440-
if not os.path.exists(suite):
1441-
mx.log("Got to revision before suite, reverting to %s" % current_commit)
1442-
SUITE.vc.update(path, rev=current_commit)
1443-
return
1444-
with open(suite) as f:
1445-
contents = f.read()
1446-
if not PY3:
1447-
contents = contents.decode()
1448-
d = {}
1443+
current_revision = parent[0]
1444+
contents = SUITE.vc.git_command(path, ["show", "%s:%s" % (current_revision, suite)])
1445+
d = {}
1446+
try:
14491447
exec(contents, d, d)
1450-
suites = d["suite"]["imports"]["suites"]
1451-
for suitedict in suites:
1452-
if suitedict["name"] in ("compiler", "truffle", "regex", "sulong"):
1453-
other_version = suitedict.get("version", "")
1454-
if other_version:
1455-
break
1448+
except:
1449+
mx.log("suite.py no longer parseable, falling back to %s" % current_commit)
1450+
return
1451+
suites = d["suite"]["imports"]["suites"]
1452+
for suitedict in suites:
1453+
if suitedict["name"] in ("compiler", "truffle", "regex", "sulong"):
1454+
other_version = suitedict.get("version", "")
1455+
if other_version:
1456+
break
14561457

14571458

14581459
# ----------------------------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)