@@ -758,11 +758,12 @@ def delete_self_if_testdownstream(args):
758
758
759
759
def update_import (name , suite_py , rev = "origin/master" ):
760
760
parent = os .path .join (SUITE .dir , ".." )
761
+ dep_dir = None
761
762
for dirpath , dirnames , _ in os .walk (parent ):
762
763
if os .path .sep in os .path .relpath (dirpath , parent ):
763
764
dirnames .clear () # we're looking for siblings or sibling-subdirs
764
- elif name in dirnames :
765
- dep_dir = os . path . join ( os . path . join ( dirpath ))
765
+ elif name in dirnames and os . path . isdir ( os . path . join ( dirpath , name , "mx.%s" % name )) :
766
+ dep_dir = dirpath
766
767
break
767
768
if not dep_dir :
768
769
mx .warn ("could not find suite %s to update" % name )
@@ -851,7 +852,7 @@ def update_import_cmd(args):
851
852
d = {}
852
853
with open (suite_py ) as f :
853
854
exec (f .read (), d , d ) # pylint: disable=exec-used;
854
- for suite in dict ["suite" ].get ("imports" , {}).get ("suites" , []):
855
+ for suite in d ["suite" ].get ("imports" , {}).get ("suites" , []):
855
856
import_name = suite ["name" ]
856
857
if suite .get ("version" ) and import_name not in local_names :
857
858
imports_to_update .add (import_name )
@@ -868,39 +869,42 @@ def update_import_cmd(args):
868
869
869
870
repos_updated = []
870
871
871
- # commit ci if dirty
872
- overlaytip = str (vc .tip (overlaydir )).strip ()
873
- if vc .isDirty (overlaydir ):
874
- vc .commit (overlaydir , "Update Python imports" )
875
- overlaytip = str (vc .tip (overlaydir )).strip ()
876
- repos_updated .append (overlaydir )
877
-
878
872
# now allow dependent repos to hook into update
879
873
output = mx .OutputCapture ()
880
874
for repo in repos :
881
875
basename = os .path .basename (repo )
882
876
cmdname = "%s-update-import" % basename
883
- is_mx_command = mx .run_mx (["help" , cmdname ], out = output , err = output , nonZeroIsFatal = False , quiet = True ) == 0
877
+ is_mx_command = mx .run_mx (["-p" , repo , " help" , cmdname ], out = output , err = output , nonZeroIsFatal = False , quiet = True ) == 0
884
878
if is_mx_command :
885
- mx .run_mx ([cmdname , "--overlaydir=%s" % overlaydir ], suite = repo , nonZeroIsFatal = True )
879
+ mx .run_mx (["-p" , repo , cmdname , "--overlaydir=%s" % overlaydir ], suite = repo , nonZeroIsFatal = True )
886
880
else :
887
881
print (mx .colorize ('%s command for %s.. skipped!' % (cmdname , basename ), color = 'magenta' , bright = True , stream = sys .stdout ))
888
882
889
- # update ci import in all our repos, commit the full update, and push verbosely
883
+ # commit ci-overlays if dirty
884
+ if vc .isDirty (overlaydir ):
885
+ vc .commit (overlaydir , "Update Python imports" )
886
+ repos_updated .append (overlaydir )
887
+
888
+ overlaytip = str (vc .tip (overlaydir )).strip ()
889
+
890
+ # update ci import in all our repos, commit the full update
890
891
prev_verbosity = mx ._opts .very_verbose
891
892
for repo in repos :
892
893
jsonnetfile = os .path .join (repo , "ci.jsonnet" )
893
894
with open (jsonnetfile , "w" ) as f :
894
895
f .write ('{ "overlay": "%s" }\n ' % overlaytip )
895
896
if vc .isDirty (repo ):
896
897
vc .commit (repo , "Update imports" )
897
- try :
898
- mx ._opts .very_verbose = True
899
- vc .git_command (repo , ["push" , "-u" , "origin" , "HEAD:%s" % current_branch ], abortOnError = True )
900
- finally :
901
- mx ._opts .very_verbose = prev_verbosity
902
898
repos_updated .append (repo )
903
899
900
+ # push all repos
901
+ for repo in repos_updated :
902
+ try :
903
+ mx ._opts .very_verbose = True
904
+ vc .git_command (repo , ["push" , "-u" , "origin" , "HEAD:%s" % current_branch ], abortOnError = True )
905
+ finally :
906
+ mx ._opts .very_verbose = prev_verbosity
907
+
904
908
if repos_updated :
905
909
mx .log ("\n " .join (["These repos were updated:" ] + repos_updated ))
906
910
0 commit comments