[PATCH 4 of 4] revert: add a `drop` action

Pierre-Yves David pierre-yves.david at ens-lyon.org
Wed Sep 10 14:29:59 CDT 2014


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

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


More information about the Mercurial-devel mailing list