@@ -337,23 +337,15 @@ def run_with_logging(cmd: Sequence[str | Path], cwd: Path | None = None) -> None
337
337
raise subprocess .CalledProcessError (return_code , cmd [0 ])
338
338
339
339
340
- def changed_files (left : Path , right : Path ) -> list [str ]:
341
- """Compute a list of different files between left and right, recursively.
342
- Resulting paths are relative to left.
343
- """
344
- changed = []
340
+ def changed_files (left : Path , right : Path ) -> int :
341
+ """Compute the number of different files in the two directory trees."""
345
342
346
- def traverse (dircmp_result : filecmp .dircmp ) -> None :
347
- base = Path (dircmp_result .left ).relative_to (left )
348
- for file in dircmp_result .diff_files :
349
- changed .append (str (base / file ))
350
- if file == "index.html" :
351
- changed .append (str (base ) + "/" )
352
- for dircomp in dircmp_result .subdirs .values ():
353
- traverse (dircomp )
343
+ def traverse (dircmp_result : filecmp .dircmp ) -> int :
344
+ changed = len (dircmp_result .diff_files )
345
+ changed += sum (map (traverse , dircmp_result .subdirs .values ()))
346
+ return changed
354
347
355
- traverse (filecmp .dircmp (left , right ))
356
- return changed
348
+ return traverse (filecmp .dircmp (left , right ))
357
349
358
350
359
351
@dataclasses .dataclass
@@ -735,10 +727,10 @@ def copy_build_to_webroot(self, http: urllib3.PoolManager) -> None:
735
727
logging .warning ("Can't change mod of %s: %s" , target , str (err ))
736
728
chgrp (target , group = self .group , recursive = True )
737
729
738
- changed = []
730
+ changed = 0
739
731
if self .includes_html :
740
732
# Copy built HTML files to webroot (default /srv/docs.python.org)
741
- changed = changed_files (self .checkout / "Doc" / "build" / "html" , target )
733
+ changed + = changed_files (self .checkout / "Doc" / "build" / "html" , target )
742
734
logging .info ("Copying HTML files to %s" , target )
743
735
chgrp (
744
736
self .checkout / "Doc" / "build" / "html/" ,
@@ -768,13 +760,12 @@ def copy_build_to_webroot(self, http: urllib3.PoolManager) -> None:
768
760
archives_dir .stat ().st_mode | stat .S_IROTH | stat .S_IXOTH
769
761
)
770
762
chgrp (archives_dir , group = self .group )
763
+ changed += 1
771
764
for dist_file in dist_dir .iterdir ():
772
765
shutil .copy2 (dist_file , archives_dir / dist_file .name )
773
- changed .append ("archives/" )
774
- for file in archives_dir .iterdir ():
775
- changed .append (f"archives/{ file .name } " )
766
+ changed += 1
776
767
777
- logging .info ("%s files changed" , len ( changed ) )
768
+ logging .info ("%s files changed" , changed )
778
769
if changed and not self .skip_cache_invalidation :
779
770
surrogate_key = f"{ self .language .tag } /{ self .version .name } "
780
771
purge_surrogate_key (http , surrogate_key )
0 commit comments