Mercurial > hg
diff mercurial/cmdutil.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 | 220506bb213e |
children | 6000f5b25c9b 877d7e1a4223 |
line wrap: on
line diff
--- a/mercurial/cmdutil.py Thu Nov 18 22:49:05 2021 +0100 +++ b/mercurial/cmdutil.py Mon Nov 22 15:58:51 2021 +0100 @@ -3646,15 +3646,14 @@ prntstatusmsg(b'drop', f) repo.dirstate.set_untracked(f) - normal = None - if node == parent: - # We're reverting to our parent. If possible, we'd like status - # to report the file as clean. We have to use normallookup for - # merges to avoid losing information about merged/dirty files. - if p2 != repo.nullid: - normal = repo.dirstate.set_tracked - else: - normal = repo.dirstate.set_clean + # We are reverting to our parent. If possible, we had like `hg status` + # to report the file as clean. We have to be less agressive for + # merges to avoid losing information about copy introduced by the merge. + # This might comes with bugs ? + reset_copy = p2 == repo.nullid + + def normal(filename): + return repo.dirstate.set_tracked(filename, reset_copy=reset_copy) newlyaddedandmodifiedfiles = set() if interactive: @@ -3749,9 +3748,6 @@ checkout(f) repo.dirstate.set_tracked(f) - normal = repo.dirstate.set_tracked - if node == parent and p2 == repo.nullid: - normal = repo.dirstate.set_clean for f in actions[b'undelete'][0]: if interactive: choice = repo.ui.promptchoice(