dirstate: requires being in a `changing_parents` `context to set_parents`
authorPierre-Yves David <pierre-yves.david@octobus.net>
Sat, 18 Feb 2023 04:10:08 +0100
changeset 50106 cdbd5f990596
parent 50105 2323b74f927b
child 50107 cad3a68c0e0c
dirstate: requires being in a `changing_parents` `context to set_parents` Enforcing proper operation scoping on all methods that mutate the dirstate will tighten correctness and reduce the risk of bugs. The context to use for this method is obvious, and all code was already compliant ☺
mercurial/dirstate.py
--- a/mercurial/dirstate.py	Tue Feb 21 00:10:20 2023 +0100
+++ b/mercurial/dirstate.py	Sat Feb 18 04:10:08 2023 +0100
@@ -479,9 +479,7 @@
     def branch(self):
         return encoding.tolocal(self._branch)
 
-    # 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)
+    @requires_changing_parents
     def setparents(self, p1, p2=None):
         """Set dirstate parents to p1 and p2.