Skip to content

Commit e6c04c7

Browse files
committed
update import command args
1 parent d66a9a8 commit e6c04c7

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

mx.graalpython/mx_graalpython.py

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
from __future__ import print_function
2626

2727
import contextlib
28+
import datetime
2829
import fnmatch
2930
import getpass
3031
import glob
@@ -349,8 +350,7 @@ def compare_unittests(args):
349350

350351
def run_cpython_test(raw_args):
351352
test_args = ['-v']
352-
import argparse
353-
parser = argparse.ArgumentParser()
353+
parser = ArgumentParser()
354354
parser.add_argument('--all', action='store_true')
355355
parser.add_argument('--gvm', dest='vm', action='store_const', const='gvm')
356356
parser.add_argument('--svm', dest='vm', action='store_const', const='svm')
@@ -1562,14 +1562,22 @@ def update_import(name, suite_py, rev="origin/master"):
15621562

15631563
def update_import_cmd(args):
15641564
"""Update our imports"""
1565+
1566+
parser = ArgumentParser()
1567+
parser.add_argument('--graal-rev', default='')
1568+
parser.add_argument('--graal-enterprise-rev', default='')
1569+
parser.add_argument('--no-pull', action='store_true')
1570+
args = parser.parse_args(args)
1571+
15651572
join = os.path.join
15661573
vc = SUITE.vc
15671574

15681575
current_branch = vc.active_branch(SUITE.dir)
1569-
if current_branch == "master":
1570-
mx.abort("updating imports should be done on a branch")
15711576
if vc.isDirty(SUITE.dir):
15721577
mx.abort("updating imports should be done on a clean branch")
1578+
if current_branch == "master":
1579+
vc.git_command(SUITE.dir, ["checkout", "-b", f"update/GR-21590/{datetime.datetime.now().strftime('%d%m%y')}"])
1580+
current_branch = vc.active_branch(SUITE.dir)
15731581

15741582
suite_py_files = []
15751583
local_names = []
@@ -1613,7 +1621,7 @@ def update_import_cmd(args):
16131621
mx.abort("overlays repo must be clean")
16141622
overlaybranch = vc.active_branch(overlaydir)
16151623
if overlaybranch == "master":
1616-
if "--no-pull" not in args:
1624+
if not args.no_pull:
16171625
vc.pull(overlaydir)
16181626
vc.set_branch(overlaydir, current_branch, with_remote=False)
16191627
vc.git_command(overlaydir, ["checkout", current_branch], abortOnError=True)
@@ -1637,7 +1645,16 @@ def update_import_cmd(args):
16371645
# now update all imports
16381646
for name in imports_to_update:
16391647
for idx, suite_py in enumerate(suite_py_files):
1640-
revisions[name] = update_import(name, suite_py, rev=("HEAD" if (idx or "--no-pull" in args) else "origin/master"))
1648+
repo_name = os.path.basename(mx.VC.get_vc_root(os.path.dirname(suite_py))[1])
1649+
if idx or not args.no_pull:
1650+
rev = "HEAD"
1651+
elif repo_name == "graal" and args.graal_rev:
1652+
rev = args.graal_rev
1653+
elif repo_name == "graal-enterprise" and args.graal_enterprise_rev:
1654+
rev = args.graal_enterprise_rev
1655+
else:
1656+
rev = "origin/master"
1657+
revisions[name] = update_import(name, suite_py, rev=rev)
16411658

16421659
# copy files we inline from our imports
16431660
shutil.copy(
@@ -1680,7 +1697,7 @@ def update_import_cmd(args):
16801697
repos_updated.append(repo)
16811698

16821699
# push all repos
1683-
if "--no-push" not in args:
1700+
if not args.no_push:
16841701
for repo in repos_updated:
16851702
try:
16861703
mx._opts.very_verbose = True

0 commit comments

Comments
 (0)