@@ -1421,38 +1421,39 @@ def checkout_find_version_for_graalvm(args):
1421
1421
path = args [0 ]
1422
1422
projectname = os .path .basename (args [0 ])
1423
1423
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 )
1424
1429
other_version = ""
1425
1430
for i in SUITE .suite_imports :
1426
1431
if i .name == "sulong" :
1427
1432
needed_version = i .version
1428
1433
break
1429
1434
current_commit = SUITE .vc .tip (path ).strip ()
1435
+ current_revision = "HEAD"
1430
1436
mx .log ("Searching %s commit that imports graal repository at %s" % (projectname , needed_version ))
1431
1437
while needed_version != other_version :
1432
1438
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 ()
1434
1440
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 )
1437
1442
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 :
1449
1447
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
1456
1457
1457
1458
1458
1459
# ----------------------------------------------------------------------------------------------------------------------
0 commit comments