[Updated] D11788: dirstate: do no use `set_clean` in revert
marmoute (Pierre-Yves David)
phabricator at mercurial-scm.org
Wed Dec 1 15:24:01 UTC 2021
Closed by commit rHG9f1b9e128788: dirstate: do no use `set_clean` in revert (authored by marmoute).
This revision was automatically updated to reflect the committed changes.
REPOSITORY
rHG Mercurial
CHANGES SINCE LAST UPDATE
https://phab.mercurial-scm.org/D11788?vs=31227&id=31250
CHANGES SINCE LAST ACTION
https://phab.mercurial-scm.org/D11788/new/
REVISION DETAIL
https://phab.mercurial-scm.org/D11788
AFFECTED FILES
mercurial/cmdutil.py
mercurial/dirstate.py
tests/test-revert.t
tests/test-win32text.t
CHANGE DETAILS
diff --git a/tests/test-win32text.t b/tests/test-win32text.t
--- a/tests/test-win32text.t
+++ b/tests/test-win32text.t
@@ -418,6 +418,7 @@
$ hg revert -a
reverting linefeed
$ hg st -q
+ M linefeed (known-bad-output !)
$ cat linefeed
% just linefeed\r (esc)
diff --git a/tests/test-revert.t b/tests/test-revert.t
--- a/tests/test-revert.t
+++ b/tests/test-revert.t
@@ -320,7 +320,7 @@
$ hg mv --force a b/b
$ hg revert b/b
- $ hg status a b/b
+ $ hg status a b/b --copies
$ cd ..
diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -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):
diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -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(
To: marmoute, #hg-reviewers, Alphare
Cc: Alphare, mercurial-patches
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mercurial-scm.org/pipermail/mercurial-patches/attachments/20211201/2624f07a/attachment-0002.html>
More information about the Mercurial-patches
mailing list