changeset 22190:55308ab8117c

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.
author Pierre-Yves David <pierre-yves.david@fb.com>
date Tue, 24 Jun 2014 17:27:18 +0100
parents cde6b489365c
children 9f9a2b79dcd7
files mercurial/cmdutil.py tests/test-largefiles.t tests/test-revert.t
diffstat 3 files changed, 7 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/cmdutil.py	Tue Jun 24 16:57:16 2014 +0100
+++ b/mercurial/cmdutil.py	Tue Jun 24 17:27:18 2014 +0100
@@ -2408,7 +2408,6 @@
             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 @@
             # 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 @@
             #   file state
             #   action
             #   make backup
+            (modified,         (actions['revert'],   False)),
             (dsmodified,       (actions['revert'],   True)),
             (missingmodified,  (actions['remove'],   True)),
             (dsadded,          (actions['revert'],   True)),
--- a/tests/test-largefiles.t	Tue Jun 24 16:57:16 2014 +0100
+++ b/tests/test-largefiles.t	Tue Jun 24 17:27:18 2014 +0100
@@ -1496,7 +1496,6 @@
   $ 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
--- a/tests/test-revert.t	Tue Jun 24 16:57:16 2014 +0100
+++ b/tests/test-revert.t	Tue Jun 24 17:27:18 2014 +0100
@@ -912,7 +912,6 @@
 
 - report "reverting" when file needs no changes
 |
-| - reverting modified_revert
 | - reverting removed_revert
 
   $ hg revert --all --rev 'desc(base)'
@@ -930,7 +929,6 @@
   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 @@
 
 - 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 @@
   ### revert for: modified_removed
   
   ### revert for: modified_revert
+  no changes needed to modified_revert
   
   ### revert for: modified_untracked-clean