diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -2407,7 +2407,6 @@ def revert(ui, repo, ctx, parents, *pats dsmodified = set(changes[0]) dsadded = set(changes[1]) dsremoved = set(changes[2]) - dsadded |= _deletedadded # only take into account for removes between wc and target clean |= dsremoved - removed @@ -2420,6 +2419,22 @@ def revert(ui, repo, ctx, parents, *pats dsmodified |= modified & dsadded # dirstate added may needs backup modified -= dsmodified + # There are three categories of added files + # + # 1. addition that just happened in the dirstate + # (should be forgotten) + # 2. file is added since target revision and has local changes + # (should be backed up and removed) + # 3. file is added since target revision and is clean + # (should be removed) + # + # However we do not need to split them yet. The current revert code + # will automatically recognize (1) when performing operation. And + # the backup system is currently unabled to handle (2). + # + # So we just put them all in the same group. + dsadded = added + # if f is a rename, update `names` to also revert the source cwd = repo.getcwd() for f in dsadded: @@ -2437,8 +2452,6 @@ def revert(ui, repo, ctx, parents, *pats missingmodified = dsmodified - smf dsmodified -= missingmodified - missingadded = dsadded - smf - dsadded -= missingadded # action to be actually performed by revert # (, message>) tuple @@ -2455,8 +2468,7 @@ def revert(ui, repo, ctx, parents, *pats (modified, (actions['revert'], False)), (dsmodified, (actions['revert'], True)), (missingmodified, (actions['remove'], True)), - (dsadded, (actions['revert'], True)), - (missingadded, (actions['remove'], False)), + (dsadded, (actions['remove'], True)), (removed, (actions['add'], True)), (dsremoved, (actions['undelete'], True)), (clean, (None, False)), diff --git a/tests/test-revert.t b/tests/test-revert.t --- a/tests/test-revert.t +++ b/tests/test-revert.t @@ -908,12 +908,6 @@ Test revert --all to "base" content check revert output -Misbehavior: - -- report "reverting" when file needs no changes -| -| - reverting removed_revert - $ hg revert --all --rev 'desc(base)' removing added_clean removing added_deleted @@ -936,7 +930,6 @@ Misbehavior: adding removed_clean reverting removed_deleted adding removed_removed - reverting removed_revert adding removed_untracked-clean adding removed_untracked-revert adding removed_untracked-wc @@ -1098,12 +1091,6 @@ Test revert to "base" content with expli revert all files individually and check the output (output is expected to be different than in the --all case) -Misbehavior: - -- fails to report no change to revert for -| -| - removed_revert - $ for file in `python ../gen-revert-cases.py filelist`; do > echo '### revert for:' $file; > hg revert $file --rev 'desc(base)'; @@ -1194,6 +1181,7 @@ Misbehavior: ### revert for: removed_removed ### revert for: removed_revert + no changes needed to removed_revert ### revert for: removed_untracked-clean