changeset 49966:380ed77e9ad3

dirstate: enforce holding the lock while doing any changes This seems like a sensible sanity check. This already caught the issue in largefile. This will catch more issue when we start using similar context manager for operation other than the parent changes.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Tue, 13 Dec 2022 12:50:52 +0100
parents 0cf4c1b80fd9
children 5698c5eee12b
files mercurial/dirstate.py
diffstat 1 files changed, 3 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/dirstate.py	Fri Jan 27 00:45:07 2023 +0100
+++ b/mercurial/dirstate.py	Tue Dec 13 12:50:52 2022 +0100
@@ -158,6 +158,9 @@
         the incoherent dirstate won't be written when wlock is
         released.
         """
+        if repo.currentwlock() is None:
+            msg = b"changing parents without holding the wlock"
+            raise error.ProgrammingError(msg)
         if self._invalidated_context:
             msg = "trying to use an invalidated dirstate before it has reset"
             raise error.ProgrammingError(msg)