changeset 50144:c6df5349183b

dirstate: add documentation about the expectation of `running_status` context
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 20 Feb 2023 15:28:08 +0100
parents ec3631290eb7
children 72ef6c4888da
files mercurial/dirstate.py
diffstat 1 files changed, 24 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/dirstate.py	Mon Feb 20 14:55:16 2023 +0100
+++ b/mercurial/dirstate.py	Mon Feb 20 15:28:08 2023 +0100
@@ -208,8 +208,30 @@
     def running_status(self, repo):
         """Wrap a status operation
 
-        Currently does nothing, but exist to let other code adds it before we
-        start enforcing it.
+        This context is not mutally exclusive with the `changing_*` context. It
+        also do not warrant for the `wlock` to be taken.
+
+        If the wlock is taken, this context will (in the future) behave in a
+        simple way, and ensure the data are scheduled for write when leaving
+        the top level context.
+
+        If the lock is not taken, it will only warrant that the data are either
+        committed (written) and rolled back (invalidated) when exiting the top
+        level context. The write/invalidate action must be performed by the
+        wrapped code.
+
+
+        The expected  logic is:
+
+        A: read the dirstate
+        B: run status
+           This might make the dirstate dirty by updating cache,
+           especially in Rust.
+        C: do more "post status fixup if relevant
+        D: try to take the w-lock (this will invalidate the changes if they were raced)
+        E0: if dirstate changed on disk → discard change (done by dirstate internal)
+        E1: elif lock was acquired → write the changes
+        E2: else → discard the changes
         """
         yield