[PATCH 4 of 4] revert: issue "no changes needed" message for files missing on both side

Pierre-Yves David pierre-yves.david at ens-lyon.org
Wed Aug 13 15:13:54 CDT 2014


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1406847806 25200
#      Thu Jul 31 16:03:26 2014 -0700
# Node ID 8bd56983281db28fbefb6058c8f6ec5dc61ea8e8
# Parent  404ea53d797b8de16c6ce15da42663b08cf9bcf7
revert: issue "no changes needed" message for files missing on both side

When a file was marked as removed in the working copy and did not existed in the
target of the revert, we did not issued any message pointing that no change was
needed to the file (implicitly saying that revert had changed the file).

We now properly issue a message in this situation. Tests change in and handful
of case where the message was documented as missing.

diff --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -2464,11 +2464,15 @@ def revert(ui, repo, ctx, parents, *pats
             # if the file is in any of this sets, it was touched in the working
             # directory parent and we are sure it needs to be reverted.
             for table, (action, backup) in disptable:
                 if abs not in table:
                     continue
-                if action is not None:
+                if action is None:
+                    if exact:
+                        ui.warn(_('no changes needed to %s\n') % rel)
+
+                else:
                     handle(action, backup)
                 break
             else:
                 # Not touched in current dirstate.
 
diff --git a/tests/test-revert.t b/tests/test-revert.t
--- a/tests/test-revert.t
+++ b/tests/test-revert.t
@@ -141,13 +141,14 @@ exact match are more silent
   A a
   $ hg rm d
   $ hg st d
   R d
 
-should silently keep d removed
+should keep d removed
 
   $ hg revert -r0 d
+  no changes needed to d
   $ hg st d
   R d
 
   $ hg update -C
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
@@ -1102,18 +1103,13 @@ revert all files individually and check 
 Misbehavior:
 
 - fails to report no change to revert for
 |
 | - clean_clean
-| - added_revert
 | - clean_revert
 | - modified_revert
 | - removed_revert
-| - added_removed
-| - added_untracked-clean
-| - added_untracked-revert
-| - added_untracked-wc
 
   $ for file in `python ../gen-revert-cases.py filelist`; do
   >   echo '### revert for:' $file;
   >   hg revert $file --rev 'desc(base)';
   >   echo
@@ -1121,18 +1117,23 @@ Misbehavior:
   ### revert for: added_clean
   
   ### revert for: added_deleted
   
   ### revert for: added_removed
+  no changes needed to added_removed
   
   ### revert for: added_revert
+  no changes needed to added_revert
   
   ### revert for: added_untracked-clean
+  no changes needed to added_untracked-clean
   
   ### revert for: added_untracked-revert
+  no changes needed to added_untracked-revert
   
   ### revert for: added_untracked-wc
+  no changes needed to added_untracked-wc
   
   ### revert for: added_wc
   
   ### revert for: clean_clean
   


More information about the Mercurial-devel mailing list