Patchwork [2,of,4] revert: have an explicit action for "forget"

login
register
mail settings
Submitter Pierre-Yves David
Date Sept. 10, 2014, 7:29 p.m.
Message ID <a53d6ad8083f8cb699b1.1410377397@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/5774/
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 1409567808 -7200
#      Mon Sep 01 12:36:48 2014 +0200
# Node ID a53d6ad8083f8cb699b18cdb8cda6665f756f424
# Parent  7434032ec939ece17af8285121e19956a072dac2
revert: have an explicit action for "forget"

The distinction between "remove" and "forget" used to be in special logic
checking for the state of the file in the dirstate. Now that we have dedicated
filtering, we can stop relying on this logic and have two distinct actions.

Patch

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2503,22 +2503,16 @@  def revert(ui, repo, ctx, parents, *pats
             target = repo.wjoin(abs)
             if os.path.lexists(target):
                 dsremovunk.add(abs)
         dsremoved -= dsremovunk
 
-        ## computation of the action to performs on `names` content.
-
-        def removeforget(abs):
-            if repo.dirstate[abs] == 'a':
-                return _('forgetting %s\n')
-            return _('removing %s\n')
-
         # action to be actually performed by revert
         # (<list of file>, message>) tuple
         actions = {'revert': ([], _('reverting %s\n')),
                    'add': ([], _('adding %s\n')),
-                   'remove': ([], removeforget),
+                   'remove': ([], _('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 +2535,11 @@  def revert(ui, repo, ctx, parents, *pats
             # Modified compared to target, local change
             (dsmodified,    actions['revert'],   backup),
             # Added since target
             (added,         actions['remove'],   discard),
             # Added in working directory
-            (dsadded,       actions['remove'],   discard),
+            (dsadded,       actions['forget'],   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
@@ -2616,14 +2610,13 @@  def _performrevert(repo, parents, ctx, a
     def checkout(f):
         fc = ctx[f]
         repo.wwrite(f, fc.data(), fc.flags())
 
     audit_path = pathutil.pathauditor(repo.root)
+    for f in actions['forget'][0]:
+        repo.dirstate.drop(f)
     for f in actions['remove'][0]:
-        if repo.dirstate[f] == 'a':
-            repo.dirstate.drop(f)
-            continue
         audit_path(f)
         try:
             util.unlinkpath(repo.wjoin(f))
         except OSError:
             pass