[PATCH] revert: hint at update if --all is not specified

Matt Mackall mpm at selenic.com
Sun Jun 12 18:04:55 CDT 2011


On Sat, 2011-06-11 at 13:04 +0200, Adrian Buehlmann wrote:
> # HG changeset patch
> # User Adrian Buehlmann <adrian at cadifra.com>
> # Date 1307788593 -7200
> # Node ID 1459d1d4fed7b449521b1c7d1a22108afc2d4185
> # Parent  81fc9678b018c928e2c5333b9055a66616db0531
> revert: hint at update if --all is not specified
> 
> and the target revision is not a parent
> 
> And we no longer say "no files or directories specified". While technically
> true, the fact that no files or directories were specified is not really the
> real reason for aborting. The real reason is that revert would revert all files.
> 
> OLD:
> 
>   $ hg -q par
>   4:8765e19eea07
> 
>   $ hg revert
>   abort: no files or directories specified
>   (use --all to revert all files)
> 
>   $ hg revert -r 2
>   abort: no files or directories specified
>   (use --all to revert all files)
> 
> NEW:
> 
>   $ hg -q par
>   4:8765e19eea07
> 
>   $ hg revert
>   abort: revert changes all files

I don't think that's an improvement. Revert doesn't necessarily change
all files, you just give it permission to change all files.

>   (use --all to force)
> 
>   $ hg revert -r 2
>   abort: revert to revision 946c41063461 changes all files
>   (use update or --all to force)
> 
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -4123,10 +4123,6 @@
>  
>      parent, p2 = repo.dirstate.parents()
>  
> -    if not pats and not opts.get('all'):
> -        raise util.Abort(_('no files or directories specified'),
> -                         hint=_('use --all to revert all files'))
> -
>      ctx = scmutil.revsingle(repo, opts.get('rev'))
>      node = ctx.node()
>      mf = ctx.manifest()
> @@ -4135,6 +4131,15 @@
>      else:
>          pmf = None
>  
> +    if not pats and not opts.get('all'):
> +        if node != parent and node != p2:
> +            msg = _("revert to revision %s changes all files") % short(node)
> +            hint = _("use update or --all to force")
> +        else:
> +            msg = _("revert changes all files")
> +            hint = _("use --all to force")
> +        raise util.Abort(msg, hint=hint)
> +
>      # need all matching names in dirstate and manifest of target rev,
>      # so have to walk both. do not print errors if files exist in one
>      # but not other.
> diff --git a/tests/test-confused-revert.t b/tests/test-confused-revert.t
> --- a/tests/test-confused-revert.t
> +++ b/tests/test-confused-revert.t
> @@ -59,8 +59,8 @@
>  Revert should fail:
>  
>    $ hg revert
> -  abort: no files or directories specified
> -  (use --all to revert all files)
> +  abort: revert changes all files
> +  (use --all to force)
>    [255]
>  
>  Revert should be ok now:
> diff --git a/tests/test-revert.t b/tests/test-revert.t
> --- a/tests/test-revert.t
> +++ b/tests/test-revert.t
> @@ -185,8 +185,8 @@
>  should fail - no arguments
>  
>    $ hg revert -rtip
> -  abort: no files or directories specified
> -  (use --all to revert all files)
> +  abort: revert to revision e9b9a7718906 changes all files
> +  (use update or --all to force)
>    [255]
>  
>  should succeed
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel


-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list