|
24 | 24 | from mypy.dmypy_util import STATUS_FILE, receive
|
25 | 25 | from mypy.gclogger import GcLogger
|
26 | 26 | from mypy.fscache import FileSystemCache
|
27 |
| -from mypy.fswatcher import FileSystemWatcher |
| 27 | +from mypy.fswatcher import FileSystemWatcher, FileData |
28 | 28 |
|
29 | 29 |
|
30 | 30 | def daemonize(func: Callable[[], None], log_file: Optional[str] = None) -> int:
|
@@ -266,11 +266,29 @@ def initialize_fine_grained(self, sources: List[mypy.build.BuildSource]) -> Dict
|
266 | 266 | manager = result.manager
|
267 | 267 | graph = result.graph
|
268 | 268 | self.fine_grained_manager = mypy.server.update.FineGrainedBuildManager(manager, graph)
|
269 |
| - status = 1 if messages else 0 |
270 |
| - self.previous_messages = messages[:] |
271 | 269 | self.fine_grained_initialized = True
|
272 | 270 | self.previous_sources = sources
|
273 | 271 | self.fscache.flush()
|
| 272 | + |
| 273 | + # If we are using the fine-grained cache, build hasn't actually done |
| 274 | + # the typechecking on the updated files yet. |
| 275 | + # Run a fine-grained update starting from the cached data |
| 276 | + if self.options.use_fine_grained_cache: |
| 277 | + # Pull times and hashes out of the saved_cache and stick them into |
| 278 | + # the fswatcher, so we pick up the changes. |
| 279 | + for meta, mypyfile, type_map in manager.saved_cache.values(): |
| 280 | + if meta.mtime is None: continue |
| 281 | + self.fswatcher.set_file_data( |
| 282 | + meta.path, |
| 283 | + FileData(st_mtime=float(meta.mtime), st_size=meta.size, md5=meta.hash)) |
| 284 | + |
| 285 | + # Run an update |
| 286 | + changed = self.find_changed(sources) |
| 287 | + if changed: |
| 288 | + messages += self.fine_grained_manager.update(changed) |
| 289 | + |
| 290 | + status = 1 if messages else 0 |
| 291 | + self.previous_messages = messages[:] |
274 | 292 | return {'out': ''.join(s + '\n' for s in messages), 'err': '', 'status': status}
|
275 | 293 |
|
276 | 294 | def fine_grained_increment(self, sources: List[mypy.build.BuildSource]) -> Dict[str, Any]:
|
|
0 commit comments