dirstate: enforce `running_status` context for calling `status`
authorPierre-Yves David <pierre-yves.david@octobus.net>
Tue, 21 Feb 2023 23:10:02 +0100
changeset 50198 03decaaf1eff
parent 50197 b583988c6c23
child 50199 b09a0afcb975
dirstate: enforce `running_status` context for calling `status` Now that the context is working as intended and that the callers are updated. We can enforce it.
mercurial/dirstate.py
--- a/mercurial/dirstate.py	Mon Feb 20 17:13:29 2023 +0100
+++ b/mercurial/dirstate.py	Tue Feb 21 23:10:02 2023 +0100
@@ -1554,9 +1554,6 @@
         )
         return (lookup, status)
 
-    # XXX since this can make the dirstate dirty (through rust), we should
-    # enforce that it is done withing an appropriate change-context that scope
-    # the change and ensure it eventually get written on disk (or rolled back)
     def status(self, match, subrepos, ignored, clean, unknown):
         """Determine the status of the working copy relative to the
         dirstate and return a pair of (unsure, status), where status is of type
@@ -1573,6 +1570,9 @@
             files that have definitely not been modified since the
             dirstate was written
         """
+        if not self._running_status:
+            msg = "Calling `status` outside a `running_status` context"
+            raise error.ProgrammingError(msg)
         listignored, listclean, listunknown = ignored, clean, unknown
         lookup, modified, added, unknown, ignored = [], [], [], [], []
         removed, deleted, clean = [], [], []