Mercurial > hg
diff mercurial/dirstate.py @ 50026:3550e4a88ccd
dirstate: add a context for tracking files change
Let us start to use it. We will enforce it later.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 26 Jan 2023 17:44:27 +0100 |
parents | d50d45cd5a5f |
children | 4f758b51bf9b |
line wrap: on
line diff
--- a/mercurial/dirstate.py Mon Feb 13 21:51:45 2023 +0100 +++ b/mercurial/dirstate.py Thu Jan 26 17:44:27 2023 +0100 @@ -92,6 +92,7 @@ CHANGE_TYPE_PARENTS = "parents" +CHANGE_TYPE_FILES = "files" @interfaceutil.implementer(intdirstate.idirstate) @@ -215,6 +216,11 @@ with self._changing(repo, CHANGE_TYPE_PARENTS) as c: yield c + @contextlib.contextmanager + def changing_files(self, repo): + with self._changing(repo, CHANGE_TYPE_FILES) as c: + yield c + # here to help migration to the new code def parentchange(self): msg = ( @@ -250,6 +256,15 @@ return False return self._change_type == CHANGE_TYPE_PARENTS + @property + def is_changing_files(self): + """Returns true if the dirstate is in the middle of a set of changes + that modify the files tracked or their sources. + """ + if self._changing_level <= 0: + return False + return self._change_type == CHANGE_TYPE_FILES + @propertycache def _map(self): """Return the dirstate contents (see documentation for dirstatemap)."""