Mercurial > hg-stable
changeset 50116:4f758b51bf9b
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.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 26 Jan 2023 17:46:54 +0100 |
parents | 3236643066c4 |
children | 64b3cc021833 |
files | mercurial/dirstate.py |
diffstat | 1 files changed, 13 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- 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