[PATCH 3 of 6] revert: process removed files missing in target as clean

Pierre-Yves David pierre-yves.david at ens-lyon.org
Thu Aug 14 16:35:57 CDT 2014


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1406942867 25200
#      Fri Aug 01 18:27:47 2014 -0700
# Node ID cfbc006d15a6f015d76f5f834856bbbc5cd73cdd
# Parent  1e832b11013b1c024a2be8976681e3fef0e8ea16
revert: process removed files missing in target as clean

If a file does not exist in target and is marked as removed in the dirstate, we
can mark it as clean. There is no changes needed to revert it.

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2420,12 +2420,12 @@ def revert(ui, repo, ctx, parents, *pats
 
         missingmodified = dsmodified - smf
         dsmodified -= missingmodified
         missingadded = dsadded - smf
         dsadded -= missingadded
-        missingremoved = dsremoved - smf
-        dsremoved -= missingremoved
+        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')),
@@ -2440,11 +2440,10 @@ def revert(ui, repo, ctx, parents, *pats
             (dsmodified,       (actions['revert'],   True)),
             (missingmodified,  (actions['remove'],   True)),
             (dsadded,          (actions['revert'],   True)),
             (missingadded,     (actions['remove'],   False)),
             (dsremoved,        (actions['undelete'], True)),
-            (missingremoved,   (None,                False)),
             (clean,            (None,                False)),
             )
 
         for abs, (rel, exact) in sorted(names.items()):
             # hash on file in target manifest (or None if missing from target)


More information about the Mercurial-devel mailing list