mercurial/dirstate.py
branchstable
changeset 50330 9fc0d244a753
parent 50267 f92afdf3cff9
child 50335 c5e93c915ab6
--- a/mercurial/dirstate.py	Tue Mar 14 14:08:38 2023 +0000
+++ b/mercurial/dirstate.py	Wed Mar 15 05:49:56 2023 +0100
@@ -200,6 +200,12 @@
         self._cwd
 
     def refresh(self):
+        # XXX if this happens, you likely did not enter the `changing_xxx`
+        # using `repo.dirstate`, so a later `repo.dirstate` accesss might call
+        # `refresh`.
+        if self.is_changing_any:
+            msg = "refreshing the dirstate in the middle of a change"
+            raise error.ProgrammingError(msg)
         if '_branch' in vars(self):
             del self._branch
         if '_map' in vars(self) and self._map.may_need_refresh():