From 9ec0f89741a49f36b8580f01450b3fa5e624bf32 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Wed, 9 Aug 2023 14:38:26 -0400 Subject: [PATCH 01/10] ENH: Say why something is out of date --- sphinx/environment/__init__.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/sphinx/environment/__init__.py b/sphinx/environment/__init__.py index d3a9b7c1e47..3dbc5932b6a 100644 --- a/sphinx/environment/__init__.py +++ b/sphinx/environment/__init__.py @@ -502,10 +502,22 @@ def get_outdated_files(self, config_changed: bool) -> tuple[set[str], set[str], # this will do the right thing when dep is absolute too deppath = path.join(self.srcdir, dep) if not path.isfile(deppath): + logger.debug( + '[build target] changed %r ' + 'missing dependency %r', + docname, + deppath) changed.add(docname) break depmtime = _last_modified_time(deppath) if depmtime > mtime: + logger.debug( + '[build target] outdated %r ' + 'from dependency %r: %s -> %s', + docname, + deppath, + datetime.utcfromtimestamp(mtime), + datetime.utcfromtimestamp(depmtime)) changed.add(docname) break except OSError: From 5a276bde86201a863dbdc52b5e0790db074586fd Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Wed, 9 Aug 2023 15:10:04 -0400 Subject: [PATCH 02/10] FIX: Tolerate huge year --- sphinx/environment/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sphinx/environment/__init__.py b/sphinx/environment/__init__.py index 3dbc5932b6a..37472387ddd 100644 --- a/sphinx/environment/__init__.py +++ b/sphinx/environment/__init__.py @@ -511,13 +511,17 @@ def get_outdated_files(self, config_changed: bool) -> tuple[set[str], set[str], break depmtime = _last_modified_time(deppath) if depmtime > mtime: + try: + depmtime_dt = datetime.utcfromtimestamp(depmtime) + except ValueError: # e.g., year 53606865 is out of range + depmtime_dt = depmtime logger.debug( '[build target] outdated %r ' 'from dependency %r: %s -> %s', docname, deppath, datetime.utcfromtimestamp(mtime), - datetime.utcfromtimestamp(depmtime)) + depmtime_dt) changed.add(docname) break except OSError: From c50ab2f2dfbac4f50e09acf98bafab029b4e6774 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Wed, 9 Aug 2023 15:30:35 -0400 Subject: [PATCH 03/10] FIX: Really tolerate --- sphinx/environment/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/sphinx/environment/__init__.py b/sphinx/environment/__init__.py index 37472387ddd..cb7c453b036 100644 --- a/sphinx/environment/__init__.py +++ b/sphinx/environment/__init__.py @@ -515,12 +515,16 @@ def get_outdated_files(self, config_changed: bool) -> tuple[set[str], set[str], depmtime_dt = datetime.utcfromtimestamp(depmtime) except ValueError: # e.g., year 53606865 is out of range depmtime_dt = depmtime + try: + mtime_dt = datetime.utcfromtimestamp(mtime) + except ValueError: + mtime_dt = mtime logger.debug( '[build target] outdated %r ' 'from dependency %r: %s -> %s', docname, deppath, - datetime.utcfromtimestamp(mtime), + mtime_dt, depmtime_dt) changed.add(docname) break From 7af71588ed839363b992bff8c856788411177d48 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Wed, 9 Aug 2023 15:33:29 -0400 Subject: [PATCH 04/10] TST: Ping From e251db5b96487f4d8750ab162d4e064b30902920 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Wed, 9 Aug 2023 15:34:52 -0400 Subject: [PATCH 05/10] FIX: mypy --- sphinx/environment/__init__.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/sphinx/environment/__init__.py b/sphinx/environment/__init__.py index cb7c453b036..50f609b2dcc 100644 --- a/sphinx/environment/__init__.py +++ b/sphinx/environment/__init__.py @@ -514,18 +514,23 @@ def get_outdated_files(self, config_changed: bool) -> tuple[set[str], set[str], try: depmtime_dt = datetime.utcfromtimestamp(depmtime) except ValueError: # e.g., year 53606865 is out of range - depmtime_dt = depmtime + depmtime_str = str(depmtime) + else: + depmtime_str = str(depmtime_dt) try: mtime_dt = datetime.utcfromtimestamp(mtime) except ValueError: - mtime_dt = mtime + mtime_str = str(mtime) + else: + mtime_str = str(mtime_dt) logger.debug( '[build target] outdated %r ' 'from dependency %r: %s -> %s', docname, deppath, - mtime_dt, - depmtime_dt) + mtime_str, + depmtime_str, + ) changed.add(docname) break except OSError: From 826b398f3fbfca087f3b4ef54037ea929c222a27 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Thu, 10 Aug 2023 09:11:48 -0400 Subject: [PATCH 06/10] TST: Dont try --- sphinx/environment/__init__.py | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/sphinx/environment/__init__.py b/sphinx/environment/__init__.py index 50f609b2dcc..8c6801ce949 100644 --- a/sphinx/environment/__init__.py +++ b/sphinx/environment/__init__.py @@ -511,18 +511,10 @@ def get_outdated_files(self, config_changed: bool) -> tuple[set[str], set[str], break depmtime = _last_modified_time(deppath) if depmtime > mtime: - try: - depmtime_dt = datetime.utcfromtimestamp(depmtime) - except ValueError: # e.g., year 53606865 is out of range - depmtime_str = str(depmtime) - else: - depmtime_str = str(depmtime_dt) - try: - mtime_dt = datetime.utcfromtimestamp(mtime) - except ValueError: - mtime_str = str(mtime) - else: - mtime_str = str(mtime_dt) + depmtime_dt = datetime.utcfromtimestamp(depmtime) + depmtime_str = str(depmtime_dt) + mtime_dt = datetime.utcfromtimestamp(mtime) + mtime_str = str(mtime_dt) logger.debug( '[build target] outdated %r ' 'from dependency %r: %s -> %s', From 2128f96346611fe3c1000c7997cbc28dc14a70de Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Thu, 10 Aug 2023 11:46:34 -0400 Subject: [PATCH 07/10] FIX: Same code --- sphinx/environment/__init__.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/sphinx/environment/__init__.py b/sphinx/environment/__init__.py index 8c6801ce949..9a0c29e4a0d 100644 --- a/sphinx/environment/__init__.py +++ b/sphinx/environment/__init__.py @@ -511,17 +511,15 @@ def get_outdated_files(self, config_changed: bool) -> tuple[set[str], set[str], break depmtime = _last_modified_time(deppath) if depmtime > mtime: - depmtime_dt = datetime.utcfromtimestamp(depmtime) - depmtime_str = str(depmtime_dt) - mtime_dt = datetime.utcfromtimestamp(mtime) - mtime_str = str(mtime_dt) + mtime_dt = datetime.fromtimestamp(mtime / 1_000_000, tz=timezone.utc) + depmtime_dt = datetime.fromtimestamp(depmtime / 1_000_000, tz=timezone.utc) logger.debug( '[build target] outdated %r ' 'from dependency %r: %s -> %s', docname, deppath, - mtime_str, - depmtime_str, + mtime_dt, + depmtime_dt, ) changed.add(docname) break From fc28f9c84576d34df27a1593e7a12b6b306a6dd5 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Thu, 10 Aug 2023 12:59:48 -0400 Subject: [PATCH 08/10] FIX: Flake --- sphinx/environment/__init__.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sphinx/environment/__init__.py b/sphinx/environment/__init__.py index 9a0c29e4a0d..7ea85508c2e 100644 --- a/sphinx/environment/__init__.py +++ b/sphinx/environment/__init__.py @@ -511,8 +511,12 @@ def get_outdated_files(self, config_changed: bool) -> tuple[set[str], set[str], break depmtime = _last_modified_time(deppath) if depmtime > mtime: - mtime_dt = datetime.fromtimestamp(mtime / 1_000_000, tz=timezone.utc) - depmtime_dt = datetime.fromtimestamp(depmtime / 1_000_000, tz=timezone.utc) + mtime_dt = datetime.fromtimestamp( + mtime / 1_000_000, tz=timezone.utc, + ) + depmtime_dt = datetime.fromtimestamp( + depmtime / 1_000_000, tz=timezone.utc, + ) logger.debug( '[build target] outdated %r ' 'from dependency %r: %s -> %s', From 1804bdd9e05acb00d75e4ead866a597d724c9eaa Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Thu, 10 Aug 2023 17:47:21 -0400 Subject: [PATCH 09/10] DOC: Document --- CHANGES | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 073d436d0cc..645063ac81b 100644 --- a/CHANGES +++ b/CHANGES @@ -35,8 +35,11 @@ Features added Patch by Latosha Maltba. * #11221: C++: Support domain objects in the table of contents. Patch by Rouslan Korneychuk. -* 10938: doctest: Add :confval:`doctest_show_successes` option. +* #10938: doctest: Add :confval:`doctest_show_successes` option. Patch by Trey Hunner. +* #11572: Improve ``debug`` logging of reasons why files are detected as out of + date. + Patch by Eric Larson. Bugs fixed ---------- From b464611fea19b998ccd9233153e168c50dc89cf5 Mon Sep 17 00:00:00 2001 From: Adam Turner <9087854+aa-turner@users.noreply.github.com> Date: Thu, 10 Aug 2023 23:46:51 +0100 Subject: [PATCH 10/10] condense --- sphinx/environment/__init__.py | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/sphinx/environment/__init__.py b/sphinx/environment/__init__.py index 373c9d3b1c2..5059861e831 100644 --- a/sphinx/environment/__init__.py +++ b/sphinx/environment/__init__.py @@ -503,10 +503,9 @@ def get_outdated_files(self, config_changed: bool) -> tuple[set[str], set[str], deppath = path.join(self.srcdir, dep) if not path.isfile(deppath): logger.debug( - '[build target] changed %r ' - 'missing dependency %r', - docname, - deppath) + '[build target] changed %r missing dependency %r', + docname, deppath, + ) changed.add(docname) break depmtime = _last_modified_time(deppath) @@ -518,12 +517,8 @@ def get_outdated_files(self, config_changed: bool) -> tuple[set[str], set[str], depmtime / 1_000_000, tz=timezone.utc, ) logger.debug( - '[build target] outdated %r ' - 'from dependency %r: %s -> %s', - docname, - deppath, - mtime_dt, - depmtime_dt, + '[build target] outdated %r from dependency %r: %s -> %s', + docname, deppath, mtime_dt, depmtime_dt, ) changed.add(docname) break