diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -2524,6 +2524,7 @@ def revert(ui, repo, ctx, parents, *pats unknown = set(changes[4]) unknown.update(changes[5]) clean = set(changes[6]) + modadded = set() # split between files known in target manifest and the others smf = set(mf) @@ -2554,6 +2555,9 @@ def revert(ui, repo, ctx, parents, *pats # distinct between dirstate remove and other removed -= dsremoved + modadded = added & dsmodified + added -= modadded + # tell newly modified apart. dsmodified &= modified dsmodified |= modified & dsadded # dirstate added may needs backup @@ -2653,6 +2657,8 @@ def revert(ui, repo, ctx, parents, *pats (added, actions['remove'], discard), # Added in working directory (dsadded, actions['forget'], discard), + # Added since target, have local modification + (modadded, actions['remove'], discard), # Added since target but file is missing in working directory (deladded, actions['drop'], discard), # Removed since target, before working copy parent