Mercurial > hg
diff mercurial/dirstate.py @ 48384:9f1b9e128788
dirstate: do no use `set_clean` in revert
The current `set_clean` usage is racy (the file might be modified between its
restoration and the `set_clean` call).
So we simply leave the file as ambiguous and the next status will fix that.
We still have to make sure the copy information is dropped, so we teach dirstate
how to do that.
The win32txt extension is confused after this because current logic is broken in
more location. However this series will ultimately fix that so we "ignore" it
for now. Fixing it now is complicated without some extra fix landing later.
Differential Revision: https://phab.mercurial-scm.org/D11788
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Mon, 22 Nov 2021 15:58:51 +0100 |
parents | 08b060abd658 |
children | 080151f18f3a |
line wrap: on
line diff
--- a/mercurial/dirstate.py Thu Nov 18 22:49:05 2021 +0100 +++ b/mercurial/dirstate.py Mon Nov 22 15:58:51 2021 +0100 @@ -452,19 +452,24 @@ return self._map.copymap @requires_no_parents_change - def set_tracked(self, filename): + def set_tracked(self, filename, reset_copy=False): """a "public" method for generic code to mark a file as tracked This function is to be called outside of "update/merge" case. For example by a command like `hg add X`. + if reset_copy is set, any existing copy information will be dropped. + return True the file was previously untracked, False otherwise. """ self._dirty = True entry = self._map.get(filename) if entry is None or not entry.tracked: self._check_new_tracked_filename(filename) - return self._map.set_tracked(filename) + pre_tracked = self._map.set_tracked(filename) + if reset_copy: + self._map.copymap.pop(filename, None) + return pre_tracked @requires_no_parents_change def set_untracked(self, filename):