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

Pierre-Yves David pierre-yves.david at ens-lyon.org
Thu Aug 14 21:35:58 UTC 2014


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at 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.

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()):



More information about the Mercurial-devel mailing list