Patchwork [4,of,6] revert: use "remove" information from both status

login
register
mail settings
Submitter Pierre-Yves David
Date Aug. 14, 2014, 9:35 p.m.
Message ID <cf3fa01f51d15a6eb039.1408052158@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/5397/
State Accepted
Headers show

Comments

Pierre-Yves David - Aug. 14, 2014, 9:35 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1403625202 -3600
#      Tue Jun 24 16:53:22 2014 +0100
# Node ID cf3fa01f51d15a6eb03957a74502d44e3f7575d2
# Parent  cfbc006d15a6f015d76f5f834856bbbc5cd73cdd
revert: use "remove" information from both status

Using status information against the target make it sure we are catching all
files that need to be re-added.

We still need to distinguish fresh removal because they use a different
message.

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2401,10 +2401,16 @@  def revert(ui, repo, ctx, parents, *pats
             dsadded    = set(changes[1])
             dsremoved  = set(changes[2])
             dsadded |= _deletedadded
             dsmodified |= _deletedmodified
 
+            # only take in account for remove that between wc and target.
+            clean |= dsremoved - removed
+            dsremoved &= removed
+            # distinct between dirstate remove and other
+            removed -= dsremoved
+
         # if f is a rename, update `names` to also revert the source
         cwd = repo.getcwd()
         for f in dsadded:
             src = repo.dirstate.copied(f)
             if src and src not in names and repo.dirstate[src] == 'r':
@@ -2420,12 +2426,10 @@  def revert(ui, repo, ctx, parents, *pats
 
         missingmodified = dsmodified - smf
         dsmodified -= missingmodified
         missingadded = dsadded - smf
         dsadded -= missingadded
-        clean |= dsremoved - smf
-        dsremoved -= clean
 
         # action to be actually performed by revert
         # (<list of file>, message>) tuple
         actions = {'revert': ([], _('reverting %s\n')),
                    'add': ([], _('adding %s\n')),
@@ -2439,10 +2443,11 @@  def revert(ui, repo, ctx, parents, *pats
             #   make backup
             (dsmodified,       (actions['revert'],   True)),
             (missingmodified,  (actions['remove'],   True)),
             (dsadded,          (actions['revert'],   True)),
             (missingadded,     (actions['remove'],   False)),
+            (removed,          (actions['add'],      True)),
             (dsremoved,        (actions['undelete'], True)),
             (clean,            (None,                False)),
             )
 
         for abs, (rel, exact) in sorted(names.items()):