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

login
register
mail settings
Submitter Pierre-Yves David
Date Aug. 13, 2014, 8:13 p.m.
Message ID <8bd56983281db28fbefb.1407960834@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/5372/
State Accepted
Headers show

Comments

Pierre-Yves David - Aug. 13, 2014, 8:13 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@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.
Augie Fackler - Aug. 14, 2014, 6:51 p.m.
On Wed, Aug 13, 2014 at 01:13:54PM -0700, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@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

Nice. Queued, probably with some English fixes in log messages as long
as I don't forget.

>
> 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
>
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel

Patch

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