# HG changeset patch # User Pierre-Yves David # Date 2014-09-01 10:36:48 # Node ID 0d57bf80c7cbf8ac497ef2727953be13c230e5be # Parent 6c52ed3f888e13291356569bc5ca1285a2626235 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. diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -2604,18 +2604,12 @@ def revert(ui, repo, ctx, parents, *pats 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 # (, 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')), @@ -2642,7 +2636,7 @@ def revert(ui, repo, ctx, parents, *pats # 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 exists at the same path @@ -2717,10 +2711,9 @@ def _performrevert(repo, parents, ctx, a 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))