25
25
from __future__ import print_function
26
26
27
27
import contextlib
28
+ import datetime
28
29
import fnmatch
29
30
import getpass
30
31
import glob
@@ -349,8 +350,7 @@ def compare_unittests(args):
349
350
350
351
def run_cpython_test (raw_args ):
351
352
test_args = ['-v' ]
352
- import argparse
353
- parser = argparse .ArgumentParser ()
353
+ parser = ArgumentParser ()
354
354
parser .add_argument ('--all' , action = 'store_true' )
355
355
parser .add_argument ('--gvm' , dest = 'vm' , action = 'store_const' , const = 'gvm' )
356
356
parser .add_argument ('--svm' , dest = 'vm' , action = 'store_const' , const = 'svm' )
@@ -1530,7 +1530,7 @@ def delete_self_if_testdownstream(args):
1530
1530
shutil .rmtree (SUITE .dir , ignore_errors = True )
1531
1531
1532
1532
1533
- def update_import (name , suite_py , rev = "origin/master" ):
1533
+ def update_import (name , suite_py , args ):
1534
1534
parent = os .path .join (SUITE .dir , ".." )
1535
1535
dep_dir = None
1536
1536
for dirpath , dirnames , _ in os .walk (parent ):
@@ -1543,9 +1543,17 @@ def update_import(name, suite_py, rev="origin/master"):
1543
1543
mx .warn ("could not find suite %s to update" % name )
1544
1544
return
1545
1545
vc = mx .VC .get_vc (dep_dir )
1546
- if rev != "HEAD" :
1547
- vc .pull (dep_dir , update = False )
1548
- vc .update (dep_dir , rev = rev )
1546
+ repo_name = os .path .basename (dep_dir )
1547
+ if repo_name == "graal" and args .graal_rev :
1548
+ rev = args .graal_rev
1549
+ elif repo_name == "graal-enterprise" and args .graal_enterprise_rev :
1550
+ rev = args .graal_enterprise_rev
1551
+ elif args .no_pull :
1552
+ rev = "HEAD"
1553
+ else :
1554
+ vc .pull (dep_dir )
1555
+ rev = "origin/master"
1556
+ vc .update (dep_dir , rev = rev , mayPull = True )
1549
1557
tip = str (vc .tip (dep_dir )).strip ()
1550
1558
contents = None
1551
1559
with open (suite_py , 'r' ) as f :
@@ -1562,14 +1570,24 @@ def update_import(name, suite_py, rev="origin/master"):
1562
1570
1563
1571
def update_import_cmd (args ):
1564
1572
"""Update our imports"""
1573
+
1574
+ parser = ArgumentParser ()
1575
+ parser .add_argument ('--graal-rev' , default = '' )
1576
+ parser .add_argument ('--graal-enterprise-rev' , default = '' )
1577
+ parser .add_argument ('--no-pull' , action = 'store_true' )
1578
+ parser .add_argument ('--no-push' , action = 'store_true' )
1579
+ parser .add_argument ('--allow-dirty' , action = 'store_true' )
1580
+ args = parser .parse_args (args )
1581
+
1565
1582
join = os .path .join
1566
1583
vc = SUITE .vc
1567
1584
1568
1585
current_branch = vc .active_branch (SUITE .dir )
1569
- if current_branch == "master" :
1570
- mx .abort ("updating imports should be done on a branch" )
1571
- if vc .isDirty (SUITE .dir ):
1586
+ if vc .isDirty (SUITE .dir ) and not args .allow_dirty :
1572
1587
mx .abort ("updating imports should be done on a clean branch" )
1588
+ if current_branch == "master" :
1589
+ vc .git_command (SUITE .dir , ["checkout" , "-b" , f"update/GR-21590/{ datetime .datetime .now ().strftime ('%d%m%y' )} " ])
1590
+ current_branch = vc .active_branch (SUITE .dir )
1573
1591
1574
1592
suite_py_files = []
1575
1593
local_names = []
@@ -1593,7 +1611,7 @@ def update_import_cmd(args):
1593
1611
1594
1612
# make sure all other repos are clean and on the same branch
1595
1613
for d in repos :
1596
- if vc .isDirty (d ):
1614
+ if vc .isDirty (d ) and not args . allow_dirty :
1597
1615
mx .abort ("repo %s is not clean" % d )
1598
1616
d_branch = vc .active_branch (d )
1599
1617
if d_branch == current_branch :
@@ -1609,11 +1627,11 @@ def update_import_cmd(args):
1609
1627
if not os .path .exists (overlaydir ):
1610
1628
mx .abort ("Overlays repo must be next to graalpython repo" )
1611
1629
vc = mx .VC .get_vc (overlaydir )
1612
- if vc .isDirty (overlaydir ):
1630
+ if vc .isDirty (overlaydir ) and not args . allow_dirty :
1613
1631
mx .abort ("overlays repo must be clean" )
1614
1632
overlaybranch = vc .active_branch (overlaydir )
1615
1633
if overlaybranch == "master" :
1616
- if "--no-pull" not in args :
1634
+ if not args . no_pull :
1617
1635
vc .pull (overlaydir )
1618
1636
vc .set_branch (overlaydir , current_branch , with_remote = False )
1619
1637
vc .git_command (overlaydir , ["checkout" , current_branch ], abortOnError = True )
@@ -1636,8 +1654,8 @@ def update_import_cmd(args):
1636
1654
revisions = {}
1637
1655
# now update all imports
1638
1656
for name in imports_to_update :
1639
- 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" ) )
1657
+ for _ , suite_py in enumerate (suite_py_files ):
1658
+ revisions [name ] = update_import (name , suite_py , args )
1641
1659
1642
1660
# copy files we inline from our imports
1643
1661
shutil .copy (
@@ -1680,7 +1698,7 @@ def update_import_cmd(args):
1680
1698
repos_updated .append (repo )
1681
1699
1682
1700
# push all repos
1683
- if "--no-push" not in args :
1701
+ if not args . no_push :
1684
1702
for repo in repos_updated :
1685
1703
try :
1686
1704
mx ._opts .very_verbose = True
0 commit comments