dirstate: enforce change context for hacky_extension_update_file
authorPierre-Yves David <pierre-yves.david@octobus.net>
Wed, 22 Feb 2023 03:42:36 +0100
changeset 50154 028fb89a0539
parent 50153 98890baf324e
child 50155 4c67862a0c49
dirstate: enforce change context for hacky_extension_update_file This was the last method not scoped yet
mercurial/dirstate.py
--- a/mercurial/dirstate.py	Wed Feb 22 04:00:30 2023 +0100
+++ b/mercurial/dirstate.py	Wed Feb 22 03:42:36 2023 +0100
@@ -786,9 +786,6 @@
             parentfiledata=parentfiledata,
         )
 
-    # XXX since this make the dirstate dirty, 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 hacky_extension_update_file(self, *args, **kwargs):
         """NEVER USE THIS, YOU DO NOT NEED IT
 
@@ -808,6 +805,9 @@
         however at the time where this is writen, this is too much of a detour
         to be considered.
         """
+        if not (self._changing_level > 0 or self._running_status > 0):
+            msg = "requires a changes context"
+            raise error.ProgrammingError(msg)
         self._update_file(
             *args,
             **kwargs,