Mercurial > hg
changeset 22208:d3659b3795e9
revert: simplify handling of `added` files
There are multiple possible cases for added files. But it's all handled by magic
much lower in the stack. We document them, simplify the codes and move on.
author | Pierre-Yves David <pierre-yves.david@fb.com> |
---|---|
date | Sat, 02 Aug 2014 11:32:24 -0700 |
parents | 8dda6f6ff564 |
children | 06fbd9518bc5 |
files | mercurial/cmdutil.py tests/test-revert.t |
diffstat | 2 files changed, 18 insertions(+), 18 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/cmdutil.py Fri Aug 15 11:48:05 2014 -0500 +++ b/mercurial/cmdutil.py Sat Aug 02 11:32:24 2014 -0700 @@ -2407,7 +2407,6 @@ 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 @@ 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 @@ missingmodified = dsmodified - smf dsmodified -= missingmodified - missingadded = dsadded - smf - dsadded -= missingadded # action to be actually performed by revert # (<list of file>, message>) tuple @@ -2455,8 +2468,7 @@ (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)),
--- a/tests/test-revert.t Fri Aug 15 11:48:05 2014 -0500 +++ b/tests/test-revert.t Sat Aug 02 11:32:24 2014 -0700 @@ -908,12 +908,6 @@ 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 @@ 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 @@ 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 @@ ### revert for: removed_removed ### revert for: removed_revert + no changes needed to removed_revert ### revert for: removed_untracked-clean