[PATCH 2 of 4 V6 STABLE] revert: be more helpful on uncommitted merges

Adrian Buehlmann adrian at cadifra.com
Tue Jun 21 03:17:49 CDT 2011


On 2011-06-21 06:11, Kevin Bullock wrote:
> # HG changeset patch
> # User Kevin Bullock <kbullock at ringworld.org>
> # Date 1308626671 18000
> # Branch stable
> # Node ID 59f92ee58bc1ff014d11d009ab8e39ae86fb5af7
> # Parent  10a8c14a8fdca3d00fee266b3af949f2bd5d74e5
> revert: be more helpful on uncommitted merges
> 
>  BEFORE:
>    $ hg revert
>    abort: no files or directories specified
>    (use --all to discard all changes)
> 
>  AFTER:
>    $ hg revert
>    abort: no files or directories specified
>    (use --all to discard all changes, or 'hg update -C .' to cancel uncommitted merge)
> 
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -4181,8 +4181,12 @@
>      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 discard all changes'))
> +        msg = _('no files or directories specified')
> +        hint = _('use --all to discard all changes')
> +        if p2 != nullid:
> +            hint = _('use --all to discard all changes, or '
> +                     "'hg update -C .' to cancel uncommitted merge")
> +        raise util.Abort(msg, hint=hint)
>  
>      ctx = scmutil.revsingle(repo, opts.get('rev'))
>      node = ctx.node()
> 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
> @@ -60,7 +60,7 @@
>  
>    $ hg revert
>    abort: no files or directories specified
> -  (use --all to discard all changes)
> +  (use --all to discard all changes, or 'hg update -C .' to cancel uncommitted merge)

This would be nice and I don't care that much about the length of this
hint, but Matt's proposed

     (uncommitted merge, use --all to discard all changes)

would be an improvement over the status quo too, so I would take either
of them instead of getting nothing changed.

Other ideas:

     (use --all to discard all changes or 'hg update -C .' to discard the pending merge)

(To be honest, I still find the --all hint pretty pointless if there is a pending
merge, but Matt is a fan of it. So let's keep that can of worms closed.)







More information about the Mercurial-devel mailing list