diff mercurial/context.py @ 49673:ae61851e6fe2 stable

dirstate: add a way to test races happening during status We add the `devel.sync.status.pre-dirstate-write-file` config option to easily test what happens when other operations happen during the window where `hg status` is done working but has not updated the cache on disk yet. We introduce the framework for testing such races too, actual tests will be added in the next changesets. For now the test is only checking dirstate-v1. We will extend the test coverage later too. Check test documentation for details. Code change from Rapha?l Gom?s <rgomes@octobus.net> Test change from Pierre-Yves David <pierre-yves.david@octobus.net>
author Rapha?l Gom?s <rgomes@octobus.net>, Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 28 Feb 2023 15:25:47 +0100
parents 2e726c934fcd
children a6b8b1ab9116
line wrap: on
line diff
--- a/mercurial/context.py	Tue Feb 28 00:01:41 2023 +0100
+++ b/mercurial/context.py	Tue Feb 28 15:25:47 2023 +0100
@@ -36,6 +36,7 @@
     sparse,
     subrepo,
     subrepoutil,
+    testing,
     util,
 )
 from .utils import (
@@ -1854,6 +1855,8 @@
 
     def _poststatusfixup(self, status, fixup):
         """update dirstate for files that are actually clean"""
+        ui = self._repo.ui
+        testing.wait_on_cfg(self._repo.ui, b'status.pre-dirstate-write-file')
         poststatus = self._repo.postdsstatus()
         if fixup or poststatus or self._repo.dirstate._dirty:
             try:
@@ -1890,9 +1893,7 @@
                         # consistency, because .hg/dirstate was
                         # already changed simultaneously after last
                         # caching (see also issue5584 for detail)
-                        self._repo.ui.debug(
-                            b'skip updating dirstate: identity mismatch\n'
-                        )
+                        ui.debug(b'skip updating dirstate: identity mismatch\n')
             except error.LockError:
                 pass
             finally: