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

login
register
mail settings
Submitter Pierre-Yves David
Date Sept. 20, 2014, 1:05 a.m.
Message ID <d615331a58705680a54d.1411175102@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/5896/
State Superseded
Headers show

Comments

Pierre-Yves David - Sept. 20, 2014, 1:05 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@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.

Patch

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