@@ -203,7 +203,10 @@ def __init__(self, result: BuildResult) -> None:
203
203
self .processed_targets : list [str ] = []
204
204
205
205
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 ,
207
210
) -> list [str ]:
208
211
"""Update previous build result by processing changed modules.
209
212
@@ -219,6 +222,7 @@ def update(
219
222
Assume this is correct; it's not validated here.
220
223
removed_modules: Modules that have been deleted since the previous update
221
224
or removed from the build.
225
+ followed: If True, the modules were found through following imports
222
226
223
227
Returns:
224
228
A list of errors.
@@ -256,7 +260,9 @@ def update(
256
260
self .blocking_error = None
257
261
258
262
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
+ )
260
266
changed_modules , (next_id , next_path ), blocker_messages = result
261
267
262
268
if blocker_messages is not None :
@@ -329,6 +335,7 @@ def update_one(
329
335
initial_set : set [str ],
330
336
removed_set : set [str ],
331
337
blocking_error : str | None ,
338
+ followed : bool ,
332
339
) -> tuple [list [tuple [str , str ]], tuple [str , str ], list [str ] | None ]:
333
340
"""Process a module from the list of changed modules.
334
341
@@ -355,7 +362,7 @@ def update_one(
355
362
)
356
363
return changed_modules , (next_id , next_path ), None
357
364
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 )
359
366
remaining , (next_id , next_path ), blocker_messages = result
360
367
changed_modules = [(id , path ) for id , path in changed_modules if id != next_id ]
361
368
changed_modules = dedupe_modules (remaining + changed_modules )
@@ -368,7 +375,7 @@ def update_one(
368
375
return changed_modules , (next_id , next_path ), blocker_messages
369
376
370
377
def update_module (
371
- self , module : str , path : str , force_removed : bool
378
+ self , module : str , path : str , force_removed : bool , followed : bool
372
379
) -> tuple [list [tuple [str , str ]], tuple [str , str ], list [str ] | None ]:
373
380
"""Update a single modified module.
374
381
@@ -380,6 +387,7 @@ def update_module(
380
387
path: File system path of the module
381
388
force_removed: If True, consider module removed from the build even if path
382
389
exists (used for removing an existing file from the build)
390
+ followed: Was this found via import following?
383
391
384
392
Returns:
385
393
Tuple with these items:
@@ -417,7 +425,7 @@ def update_module(
417
425
manager .errors .reset ()
418
426
self .processed_targets .append (module )
419
427
result = update_module_isolated (
420
- module , path , manager , previous_modules , graph , force_removed
428
+ module , path , manager , previous_modules , graph , force_removed , followed
421
429
)
422
430
if isinstance (result , BlockedUpdate ):
423
431
# Blocking error -- just give up
@@ -552,6 +560,7 @@ def update_module_isolated(
552
560
previous_modules : dict [str , str ],
553
561
graph : Graph ,
554
562
force_removed : bool ,
563
+ followed : bool ,
555
564
) -> UpdateResult :
556
565
"""Build a new version of one changed module only.
557
566
@@ -575,7 +584,7 @@ def update_module_isolated(
575
584
delete_module (module , path , graph , manager )
576
585
return NormalUpdate (module , path , [], None )
577
586
578
- sources = get_sources (manager .fscache , previous_modules , [(module , path )])
587
+ sources = get_sources (manager .fscache , previous_modules , [(module , path )], followed )
579
588
580
589
if module in manager .missing_modules :
581
590
manager .missing_modules .remove (module )
@@ -728,12 +737,15 @@ def get_module_to_path_map(graph: Graph) -> dict[str, str]:
728
737
729
738
730
739
def 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 ,
732
744
) -> list [BuildSource ]:
733
745
sources = []
734
746
for id , path in changed_modules :
735
747
if fscache .isfile (path ):
736
- sources .append (BuildSource (path , id , None ))
748
+ sources .append (BuildSource (path , id , None , followed = followed ))
737
749
return sources
738
750
739
751
0 commit comments