# HG changeset patch # User Pierre-Yves David # Date 2014-08-30 00:25:23 # Node ID 5e16fe6fdd32124c3295db5ec40b076084cc5bd4 # Parent bcab7bc7280e1a4ecf9e2c7f3600caac40fd0a1b revert: add a `drop` action This prevents the need for 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 @@ -2613,6 +2613,7 @@ def revert(ui, repo, ctx, parents, *pats 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')), @@ -2642,7 +2643,7 @@ def revert(ui, repo, ctx, parents, *pats # 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 exists at the same path @@ -2721,10 +2722,10 @@ def _performrevert(repo, parents, ctx, a 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