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

login
register
mail settings
Submitter Pierre-Yves David
Date Sept. 30, 2014, 6:05 p.m.
Message ID <a58e6d9115fca974a01c.1412100339@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/6049/
State Accepted
Headers show

Comments

Pierre-Yves David - Sept. 30, 2014, 6:05 p.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 a58e6d9115fca974a01c41ee68fe4619c072792c
# Parent  9d3552b955c8cdffcb7e4d0bf88983abc2fede16
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
@@ -2513,10 +2513,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
@@ -2543,10 +2544,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
 
@@ -2641,10 +2645,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