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

login
register
mail settings
Submitter Pierre-Yves David
Date Aug. 14, 2014, 9:35 p.m.
Message ID <cfbc006d15a6f015d76f.1408052157@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/5398/
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 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.

Patch

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)