dirstate: enforce the use of `changing_files` context to change tracking
Now that everything is using the new context, we can start enforcing its usage.
--- a/mercurial/dirstate.py Tue Dec 13 03:55:14 2022 +0100
+++ b/mercurial/dirstate.py Thu Jan 26 17:46:54 2023 +0100
@@ -80,6 +80,17 @@
return wrap
+def requires_changing_files(func):
+ def wrap(self, *args, **kwargs):
+ if not self.is_changing_files:
+ msg = 'calling `%s` outside of a `changing_files`'
+ msg %= func.__name__
+ raise error.ProgrammingError(msg)
+ return func(self, *args, **kwargs)
+
+ return wrap
+
+
def requires_not_changing_parents(func):
def wrap(self, *args, **kwargs):
if self.is_changing_parents:
@@ -539,6 +550,7 @@
return self._map.copymap
@requires_not_changing_parents
+ @requires_changing_files
def set_tracked(self, filename, reset_copy=False):
"""a "public" method for generic code to mark a file as tracked
@@ -561,6 +573,7 @@
return pre_tracked
@requires_not_changing_parents
+ @requires_changing_files
def set_untracked(self, filename):
"""a "public" method for generic code to mark a file as untracked