comparison mercurial/context.py @ 50215: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
comparison
equal deleted inserted replaced
50214:8e0d823ef182 50215:ae61851e6fe2
34 repoview, 34 repoview,
35 scmutil, 35 scmutil,
36 sparse, 36 sparse,
37 subrepo, 37 subrepo,
38 subrepoutil, 38 subrepoutil,
39 testing,
39 util, 40 util,
40 ) 41 )
41 from .utils import ( 42 from .utils import (
42 dateutil, 43 dateutil,
43 stringutil, 44 stringutil,
1852 1853
1853 return modified, deleted, clean, fixup 1854 return modified, deleted, clean, fixup
1854 1855
1855 def _poststatusfixup(self, status, fixup): 1856 def _poststatusfixup(self, status, fixup):
1856 """update dirstate for files that are actually clean""" 1857 """update dirstate for files that are actually clean"""
1858 ui = self._repo.ui
1859 testing.wait_on_cfg(self._repo.ui, b'status.pre-dirstate-write-file')
1857 poststatus = self._repo.postdsstatus() 1860 poststatus = self._repo.postdsstatus()
1858 if fixup or poststatus or self._repo.dirstate._dirty: 1861 if fixup or poststatus or self._repo.dirstate._dirty:
1859 try: 1862 try:
1860 oldid = self._repo.dirstate.identity() 1863 oldid = self._repo.dirstate.identity()
1861 1864
1888 else: 1891 else:
1889 # in this case, writing changes out breaks 1892 # in this case, writing changes out breaks
1890 # consistency, because .hg/dirstate was 1893 # consistency, because .hg/dirstate was
1891 # already changed simultaneously after last 1894 # already changed simultaneously after last
1892 # caching (see also issue5584 for detail) 1895 # caching (see also issue5584 for detail)
1893 self._repo.ui.debug( 1896 ui.debug(b'skip updating dirstate: identity mismatch\n')
1894 b'skip updating dirstate: identity mismatch\n'
1895 )
1896 except error.LockError: 1897 except error.LockError:
1897 pass 1898 pass
1898 finally: 1899 finally:
1899 # Even if the wlock couldn't be grabbed, clear out the list. 1900 # Even if the wlock couldn't be grabbed, clear out the list.
1900 self._repo.clearpostdsstatus() 1901 self._repo.clearpostdsstatus()