@@ -337,23 +337,15 @@ def run_with_logging(cmd: Sequence[str | Path], cwd: Path | None = None) -> None
337337raise subprocess .CalledProcessError (return_code ,cmd [0 ])
338338
339339
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."""
345342
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
354347
355- traverse (filecmp .dircmp (left ,right ))
356- return changed
348+ return traverse (filecmp .dircmp (left ,right ))
357349
358350
359351@dataclasses .dataclass
@@ -735,10 +727,10 @@ def copy_build_to_webroot(self, http: urllib3.PoolManager) -> None:
735727logging .warning ("Can't change mod of %s: %s" ,target ,str (err ))
736728chgrp (target ,group = self .group ,recursive = True )
737729
738- changed = []
730+ changed = 0
739731if self .includes_html :
740732# 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 )
742734logging .info ("Copying HTML files to %s" ,target )
743735chgrp (
744736self .checkout / "Doc" / "build" / "html/" ,
@@ -768,13 +760,12 @@ def copy_build_to_webroot(self, http: urllib3.PoolManager) -> None:
768760archives_dir .stat ().st_mode | stat .S_IROTH | stat .S_IXOTH
769761 )
770762chgrp (archives_dir ,group = self .group )
763+ changed += 1
771764for dist_file in dist_dir .iterdir ():
772765shutil .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
776767
777- logging .info ("%s files changed" ,len ( changed ) )
768+ logging .info ("%s files changed" ,changed )
778769if changed and not self .skip_cache_invalidation :
779770surrogate_key = f"{ self .language .tag } /{ self .version .name } "
780771purge_surrogate_key (http ,surrogate_key )