@@ -203,7 +203,10 @@ def __init__(self, result: BuildResult) -> None:
203203 self .processed_targets : list [str ] = []
204204
205205 def update (
206- self , changed_modules : list [tuple [str , str ]], removed_modules : list [tuple [str , str ]]
206+ self ,
207+ changed_modules : list [tuple [str , str ]],
208+ removed_modules : list [tuple [str , str ]],
209+ followed : bool = False ,
207210 ) -> list [str ]:
208211 """Update previous build result by processing changed modules.
209212
@@ -219,6 +222,7 @@ def update(
219222 Assume this is correct; it's not validated here.
220223 removed_modules: Modules that have been deleted since the previous update
221224 or removed from the build.
225+ followed: If True, the modules were found through following imports
222226
223227 Returns:
224228 A list of errors.
@@ -256,7 +260,9 @@ def update(
256260 self .blocking_error = None
257261
258262 while True :
259- result = self .update_one (changed_modules , initial_set , removed_set , blocking_error )
263+ result = self .update_one (
264+ changed_modules , initial_set , removed_set , blocking_error , followed
265+ )
260266 changed_modules , (next_id , next_path ), blocker_messages = result
261267
262268 if blocker_messages is not None :
@@ -329,6 +335,7 @@ def update_one(
329335 initial_set : set [str ],
330336 removed_set : set [str ],
331337 blocking_error : str | None ,
338+ followed : bool ,
332339 ) -> tuple [list [tuple [str , str ]], tuple [str , str ], list [str ] | None ]:
333340 """Process a module from the list of changed modules.
334341
@@ -355,7 +362,7 @@ def update_one(
355362 )
356363 return changed_modules , (next_id , next_path ), None
357364
358- result = self .update_module (next_id , next_path , next_id in removed_set )
365+ result = self .update_module (next_id , next_path , next_id in removed_set , followed )
359366 remaining , (next_id , next_path ), blocker_messages = result
360367 changed_modules = [(id , path ) for id , path in changed_modules if id != next_id ]
361368 changed_modules = dedupe_modules (remaining + changed_modules )
@@ -368,7 +375,7 @@ def update_one(
368375 return changed_modules , (next_id , next_path ), blocker_messages
369376
370377 def update_module (
371- self , module : str , path : str , force_removed : bool
378+ self , module : str , path : str , force_removed : bool , followed : bool
372379 ) -> tuple [list [tuple [str , str ]], tuple [str , str ], list [str ] | None ]:
373380 """Update a single modified module.
374381
@@ -380,6 +387,7 @@ def update_module(
380387 path: File system path of the module
381388 force_removed: If True, consider module removed from the build even if path
382389 exists (used for removing an existing file from the build)
390+ followed: Was this found via import following?
383391
384392 Returns:
385393 Tuple with these items:
@@ -417,7 +425,7 @@ def update_module(
417425 manager .errors .reset ()
418426 self .processed_targets .append (module )
419427 result = update_module_isolated (
420- module , path , manager , previous_modules , graph , force_removed
428+ module , path , manager , previous_modules , graph , force_removed , followed
421429 )
422430 if isinstance (result , BlockedUpdate ):
423431 # Blocking error -- just give up
@@ -552,6 +560,7 @@ def update_module_isolated(
552560 previous_modules : dict [str , str ],
553561 graph : Graph ,
554562 force_removed : bool ,
563+ followed : bool ,
555564) -> UpdateResult :
556565 """Build a new version of one changed module only.
557566
@@ -575,7 +584,7 @@ def update_module_isolated(
575584 delete_module (module , path , graph , manager )
576585 return NormalUpdate (module , path , [], None )
577586
578- sources = get_sources (manager .fscache , previous_modules , [(module , path )])
587+ sources = get_sources (manager .fscache , previous_modules , [(module , path )], followed )
579588
580589 if module in manager .missing_modules :
581590 manager .missing_modules .remove (module )
@@ -728,12 +737,15 @@ def get_module_to_path_map(graph: Graph) -> dict[str, str]:
728737
729738
730739def get_sources (
731- fscache : FileSystemCache , modules : dict [str , str ], changed_modules : list [tuple [str , str ]]
740+ fscache : FileSystemCache ,
741+ modules : dict [str , str ],
742+ changed_modules : list [tuple [str , str ]],
743+ followed : bool ,
732744) -> list [BuildSource ]:
733745 sources = []
734746 for id , path in changed_modules :
735747 if fscache .isfile (path ):
736- sources .append (BuildSource (path , id , None ))
748+ sources .append (BuildSource (path , id , None , followed = followed ))
737749 return sources
738750
739751
0 commit comments