revert: explicitly track added but deleted file
authorPierre-Yves David <pierre-yves.david@fb.com>
Sat, 30 Aug 2014 02:23:25 +0200
changeset 22490 bcab7bc7280e
parent 22489 0d57bf80c7cb
child 22491 5e16fe6fdd32
revert: explicitly track added but deleted file Added + deleted file are files that need to be untracked from the dirstate but that are already missing on disk. The current `_performrevert` code is handling that with exception catching. We will be able to do better with a dedicated set.
mercurial/cmdutil.py
--- a/mercurial/cmdutil.py	Mon Sep 01 12:36:48 2014 +0200
+++ b/mercurial/cmdutil.py	Sat Aug 30 02:23:25 2014 +0200
@@ -2523,9 +2523,8 @@
         smf = set(mf)
 
         # determine the exact nature of the deleted changesets
-        _deletedadded = _deleted - smf
-        deleted = _deleted - _deletedadded
-        added |= _deletedadded
+        deladded = _deleted - smf
+        deleted = _deleted - deladded
 
         # We need to account for the state of file in the dirstate
         #
@@ -2586,6 +2585,11 @@
                 added.add(abs)
         dsadded -= added
 
+        for abs in deladded:
+            if repo.dirstate[abs] == 'a':
+                dsadded.add(abs)
+        deladded -= dsadded
+
         # For files marked as removed, we check if an unknown file is present at
         # the same path. If a such file exists it may need to be backed up.
         # Making the distinction at this stage helps have simpler backup
@@ -2637,6 +2641,8 @@
             (added,         actions['remove'],   discard),
             # Added in working directory
             (dsadded,       actions['forget'],   discard),
+            # Added since target but file is missing in working directory
+            (deladded,      actions['remove'],   discard),
             # Removed since  target, before working copy parent
             (removed,       actions['add'],      discard),
             # Same as `removed` but an unknown file exists at the same path