# HG changeset patch # User Pierre-Yves David # Date 1674751614 -3600 # Node ID 4f758b51bf9b4f23bf1554b85d0efef75c6b5978 # Parent 3236643066c489f25d227c6540f9d838d61e1cf7 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. diff -r 3236643066c4 -r 4f758b51bf9b mercurial/dirstate.py --- 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