[PATCH 3 of 4] revert: track added files with local modifications

Pierre-Yves David pierre-yves.david at ens-lyon.org
Fri Sep 19 20:05:02 CDT 2014


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1409359148 -7200
#      Sat Aug 30 02:39:08 2014 +0200
# Node ID d615331a58705680a54d72ee07269083018a4e60
# Parent  e5fd2c86f4a761efa634c4bf3dd825165f16fadb
revert: track added files with local modifications

Those files need to be backed up but are currently not. We compute the set of
them to be able to use a different backup strategy in the next changeset.

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2516,10 +2516,11 @@ def revert(ui, repo, ctx, parents, *pats
         removed  = set(changes[2])
         _deleted = set(changes[3])
         unknown  = set(changes[4])
         unknown.update(changes[5])
         clean    = set(changes[6])
+        modadded = set()
 
         # split between files known in target manifest and the others
         smf = set(mf)
 
         # determine the exact nature of the deleted changesets
@@ -2546,10 +2547,13 @@ def revert(ui, repo, ctx, parents, *pats
             clean |= dsremoved - removed
             dsremoved &= removed
             # distinct between dirstate remove and other
             removed -= dsremoved
 
+            modadded = added & dsmodified
+            added -= modadded
+
             # tell newly modified apart.
             dsmodified &= modified
             dsmodified |= modified & dsadded # dirstate added may needs backup
             modified -= dsmodified
 
@@ -2643,10 +2647,12 @@ def revert(ui, repo, ctx, parents, *pats
             (dsmodified,    actions['revert'],   backup),
             # Added since target
             (added,         actions['remove'],   discard),
             # Added in working directory
             (dsadded,       actions['forget'],   discard),
+            # Added since target, have local modification
+            (modadded,      actions['remove'],   discard),
             # Added since target but file is missing in working directory
             (deladded,      actions['drop'],   discard),
             # Removed since  target, before working copy parent
             (removed,       actions['add'],      discard),
             # Same as `removed` but an unknown file exists at the same path


More information about the Mercurial-devel mailing list