Read about our upcoming Code of Conduct on this issue

This instance will be upgraded to Heptapod 0.28.1 on 2022-01-26 at 16:00 UTC+1 (a few minutes of down time)

Commit 95500544 authored by Pierre-Yves David's avatar Pierre-Yves David 🐙
Browse files

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
parent 4237be881bb6
......@@ -3646,15 +3646,14 @@ def _performrevert(
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 @@ def _performrevert(
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(
......
......@@ -452,19 +452,24 @@ class dirstate(object):
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):
......
......@@ -320,7 +320,7 @@ Also true for move overwriting an existing file
$ hg mv --force a b/b
$ hg revert b/b
$ hg status a b/b
$ hg status a b/b --copies
$ cd ..
......
......@@ -418,6 +418,7 @@ Disable warning:
$ hg revert -a
reverting linefeed
$ hg st -q
M linefeed (known-bad-output !)
$ cat linefeed
% just linefeed\r (esc)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment