Mercurial > hg
diff mercurial/dirstate.py @ 47599:cce51119bfe6
dirstate: add a `set_untracked` method for "hg remove"-like usage
This is a step further toward clarifying the semantic of various dirstate call.
See the justification for adding `set_tracked` for details.
Differential Revision: https://phab.mercurial-scm.org/D11019
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Thu, 08 Jul 2021 00:54:40 +0200 |
parents | 0cef28b121a4 |
children | e2e72daac90b |
line wrap: on
line diff
--- a/mercurial/dirstate.py Thu Jul 08 04:32:31 2021 +0200 +++ b/mercurial/dirstate.py Thu Jul 08 00:54:40 2021 +0200 @@ -480,6 +480,25 @@ return True return False + @requires_no_parents_change + def set_untracked(self, filename): + """a "public" method for generic code to mark a file as untracked + + This function is to be called outside of "update/merge" case. For + example by a command like `hg remove X`. + + return True the file was previously tracked, False otherwise. + """ + entry = self._map.get(filename) + if entry is None: + return False + elif entry.added: + self._drop(filename) + return True + else: + self._remove(filename) + return True + @requires_parents_change def update_file_reference( self,