# HG changeset patch # User Pierre-Yves David # Date 2014-06-24 16:27:18 # Node ID 55308ab8117c3d1115ddb6e088bcd369fd76f9eb # Parent cde6b489365cc042476e95f850d8e2b42799e41f revert: use modified information from both statuses Using status information against the target ensures we are catching all files with modifications that need reverting. We still need to distinguish fresh modifications for backup purpose. test-largefile is affected because it reverted a file that needs no content change. diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py --- a/mercurial/cmdutil.py +++ b/mercurial/cmdutil.py @@ -2408,7 +2408,6 @@ def revert(ui, repo, ctx, parents, *pats dsadded = set(changes[1]) dsremoved = set(changes[2]) dsadded |= _deletedadded - dsmodified |= _deletedmodified # only take into account for removes between wc and target clean |= dsremoved - removed @@ -2416,6 +2415,11 @@ def revert(ui, repo, ctx, parents, *pats # distinct between dirstate remove and other removed -= dsremoved + # tell newly modified apart. + dsmodified &= modified + dsmodified |= modified & dsadded # dirstate added may needs backup + modified -= dsmodified + # if f is a rename, update `names` to also revert the source cwd = repo.getcwd() for f in dsadded: @@ -2448,6 +2452,7 @@ def revert(ui, repo, ctx, parents, *pats # file state # action # make backup + (modified, (actions['revert'], False)), (dsmodified, (actions['revert'], True)), (missingmodified, (actions['remove'], True)), (dsadded, (actions['revert'], True)), diff --git a/tests/test-largefiles.t b/tests/test-largefiles.t --- a/tests/test-largefiles.t +++ b/tests/test-largefiles.t @@ -1496,7 +1496,6 @@ revert some files to an older revision $ cat sub2/large6 large6 $ hg revert --no-backup -C -r '.^' sub2 - reverting .hglf/sub2/large6 (glob) $ hg revert --no-backup sub2 reverting .hglf/sub2/large6 (glob) $ hg status diff --git a/tests/test-revert.t b/tests/test-revert.t --- a/tests/test-revert.t +++ b/tests/test-revert.t @@ -912,7 +912,6 @@ Misbehavior: - report "reverting" when file needs no changes | -| - reverting modified_revert | - reverting removed_revert $ hg revert --all --rev 'desc(base)' @@ -930,7 +929,6 @@ Misbehavior: reverting modified_clean reverting modified_deleted undeleting modified_removed - reverting modified_revert undeleting modified_untracked-clean undeleting modified_untracked-revert undeleting modified_untracked-wc @@ -1104,7 +1102,6 @@ Misbehavior: - fails to report no change to revert for | -| - modified_revert | - removed_revert $ for file in `python ../gen-revert-cases.py filelist`; do @@ -1180,6 +1177,7 @@ Misbehavior: ### revert for: modified_removed ### revert for: modified_revert + no changes needed to modified_revert ### revert for: modified_untracked-clean