@@ -758,11 +758,12 @@ def delete_self_if_testdownstream(args):
758758
759759def update_import (name , suite_py , rev = "origin/master" ):
760760 parent = os .path .join (SUITE .dir , ".." )
761+ dep_dir = None
761762 for dirpath , dirnames , _ in os .walk (parent ):
762763 if os .path .sep in os .path .relpath (dirpath , parent ):
763764 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
766767 break
767768 if not dep_dir :
768769 mx .warn ("could not find suite %s to update" % name )
@@ -851,7 +852,7 @@ def update_import_cmd(args):
851852 d = {}
852853 with open (suite_py ) as f :
853854 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" , []):
855856 import_name = suite ["name" ]
856857 if suite .get ("version" ) and import_name not in local_names :
857858 imports_to_update .add (import_name )
@@ -868,39 +869,42 @@ def update_import_cmd(args):
868869
869870 repos_updated = []
870871
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-
878872 # now allow dependent repos to hook into update
879873 output = mx .OutputCapture ()
880874 for repo in repos :
881875 basename = os .path .basename (repo )
882876 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
884878 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 )
886880 else :
887881 print (mx .colorize ('%s command for %s.. skipped!' % (cmdname , basename ), color = 'magenta' , bright = True , stream = sys .stdout ))
888882
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
890891 prev_verbosity = mx ._opts .very_verbose
891892 for repo in repos :
892893 jsonnetfile = os .path .join (repo , "ci.jsonnet" )
893894 with open (jsonnetfile , "w" ) as f :
894895 f .write ('{ "overlay": "%s" }\n ' % overlaytip )
895896 if vc .isDirty (repo ):
896897 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
902898 repos_updated .append (repo )
903899
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+
904908 if repos_updated :
905909 mx .log ("\n " .join (["These repos were updated:" ] + repos_updated ))
906910
0 commit comments