Patchwork [4,of,4] revert: add a `drop` action

login
register
mail settings
Submitter Pierre-Yves David
Date Sept. 10, 2014, 7:29 p.m.
Message ID <2eeb360edc896fc011c0.1410377399@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/5773/
State Accepted
Headers show

Comments

Pierre-Yves David - Sept. 10, 2014, 7:29 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1409358323 -7200
#      Sat Aug 30 02:25:23 2014 +0200
# Node ID 2eeb360edc896fc011c062fba486c8abc3794557
# Parent  84ecfe0c320d1ee0eff3d98074b57b3d168ff9e7
revert: add a `drop` action

This prevent the needs of a try except in the `_performrevert` code.
Durham Goode - Sept. 19, 2014, 8:13 p.m.
On 9/10/14, 12:29 PM, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1409358323 -7200
> #      Sat Aug 30 02:25:23 2014 +0200
> # Node ID 2eeb360edc896fc011c062fba486c8abc3794557
> # Parent  84ecfe0c320d1ee0eff3d98074b57b3d168ff9e7
> revert: add a `drop` action
>
> This prevent the needs of a try except in the `_performrevert` code.
>
Queued this series to the clowncopter repo.

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2512,10 +2512,11 @@  def revert(ui, repo, ctx, parents, *pats
         # action to be actually performed by revert
         # (<list of file>, message>) tuple
         actions = {'revert': ([], _('reverting %s\n')),
                    'add': ([], _('adding %s\n')),
                    'remove': ([], _('removing %s\n')),
+                   'drop': ([], _('removing %s\n')),
                    'forget': ([], _('forgetting %s\n')),
                    'undelete': ([], _('undeleting %s\n')),
                    'noop': (None, _('no changes needed to %s\n')),
                    'unknown': (None, _('file not managed: %s\n')),
                   }
@@ -2541,11 +2542,11 @@  def revert(ui, repo, ctx, parents, *pats
             # Added since target
             (added,         actions['remove'],   discard),
             # Added in working directory
             (dsadded,       actions['forget'],   discard),
             # Added since target but file is missing in working directory
-            (deladded,      actions['remove'],   discard),
+            (deladded,      actions['drop'],     discard),
             # Removed since  target, before working copy parent
             (removed,       actions['add'],      discard),
             # Same as `removed` but an unknown file exist at the same path
             (removunk,      actions['add'],      backup),
             # Removed since targe, marked as such in working copy parent
@@ -2620,14 +2621,14 @@  def _performrevert(repo, parents, ctx, a
     audit_path = pathutil.pathauditor(repo.root)
     for f in actions['forget'][0]:
         repo.dirstate.drop(f)
     for f in actions['remove'][0]:
         audit_path(f)
-        try:
-            util.unlinkpath(repo.wjoin(f))
-        except OSError:
-            pass
+        util.unlinkpath(repo.wjoin(f))
+        repo.dirstate.remove(f)
+    for f in actions['drop'][0]:
+        audit_path(f)
         repo.dirstate.remove(f)
 
     normal = None
     if node == parent:
         # We're reverting to our parent. If possible, we'd like status