diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -2640,6 +2640,10 @@ def revert(ui, repo, ctx, parents, *pats if opts.get('no_backup'): backup = check = discard + backupanddel = actions['remove'] + if not opts.get('no_backup'): + backupanddel = actions['drop'] + disptable = ( # dispatch table: # file state @@ -2658,7 +2662,7 @@ def revert(ui, repo, ctx, parents, *pats # Added in working directory (dsadded, actions['forget'], discard), # Added since target, have local modification - (modadded, actions['remove'], discard), + (modadded, backupanddel, backup), # Added since target but file is missing in working directory (deladded, actions['drop'], discard), # Removed since target, before working copy parent diff --git a/tests/test-revert.t b/tests/test-revert.t --- a/tests/test-revert.t +++ b/tests/test-revert.t @@ -940,16 +940,12 @@ Compare resulting directory with revert The diff is filtered to include change only. The only difference should be additional `.orig` backup file when applicable. -Misbehavior: - -- no backup for -| - added_wc (DATA LOSS) - $ python ../dircontent.py > ../content-base-all.txt $ cd .. $ diff -U 0 -- content-base.txt content-base-all.txt | grep _ +parent added_untracked-clean +wc added_untracked-wc + +wc added_wc.orig +wc clean_untracked-wc.orig +wc clean_wc.orig +wc missing_untracked-wc