Merge pull request #7830 from shimizukawa/debug-log-for-change-detection

Add debug logs for change detection of sources and templates
This commit is contained in:
Takayuki SHIMIZUKAWA
2020-06-18 05:35:51 +09:00
committed by GitHub
2 changed files with 19 additions and 0 deletions

View File

@@ -12,6 +12,7 @@ import html
import posixpath
import re
import sys
from datetime import datetime
from os import path
from typing import Any, Dict, IO, Iterable, Iterator, List, Set, Tuple, Type
@@ -344,6 +345,7 @@ class StandaloneHTMLBuilder(Builder):
buildinfo = BuildInfo.load(fp)
if self.build_info != buildinfo:
logger.debug('[build target] did not match: build_info ')
yield from self.env.found_docs
return
except ValueError as exc:
@@ -358,6 +360,7 @@ class StandaloneHTMLBuilder(Builder):
template_mtime = 0
for docname in self.env.found_docs:
if docname not in self.env.all_docs:
logger.debug('[build target] did not in env: %r', docname)
yield docname
continue
targetname = self.get_outfilename(docname)
@@ -369,6 +372,14 @@ class StandaloneHTMLBuilder(Builder):
srcmtime = max(path.getmtime(self.env.doc2path(docname)),
template_mtime)
if srcmtime > targetmtime:
logger.debug(
'[build target] targetname %r(%s), template(%s), docname %r(%s)',
targetname,
datetime.utcfromtimestamp(targetmtime),
datetime.utcfromtimestamp(template_mtime),
docname,
datetime.utcfromtimestamp(path.getmtime(self.env.doc2path(docname))),
)
yield docname
except OSError:
# source doesn't exist anymore

View File

@@ -12,6 +12,7 @@ import os
import pickle
from collections import defaultdict
from copy import copy
from datetime import datetime
from os import path
from typing import Any, Callable, Dict, Generator, Iterator, List, Set, Tuple, Union
from typing import TYPE_CHECKING
@@ -391,21 +392,28 @@ class BuildEnvironment:
else:
for docname in self.found_docs:
if docname not in self.all_docs:
logger.debug('[build target] added %r', docname)
added.add(docname)
continue
# if the doctree file is not there, rebuild
filename = path.join(self.doctreedir, docname + '.doctree')
if not path.isfile(filename):
logger.debug('[build target] changed %r', docname)
changed.add(docname)
continue
# check the "reread always" list
if docname in self.reread_always:
logger.debug('[build target] changed %r', docname)
changed.add(docname)
continue
# check the mtime of the document
mtime = self.all_docs[docname]
newmtime = path.getmtime(self.doc2path(docname))
if newmtime > mtime:
logger.debug('[build target] outdated %r: %s -> %s',
docname,
datetime.utcfromtimestamp(mtime),
datetime.utcfromtimestamp(newmtime))
changed.add(docname)
continue
# finally, check the mtime of dependencies