[PATCH] revert: improve merge advice and favor its error over all

Greg Ward greg-hg at gerg.ca
Sun Nov 21 10:33:06 CST 2010


On Sat, Nov 20, 2010 at 1:45 PM, timeless <timeless at gmail.com> wrote:
> # HG changeset patch
> # User timeless <timeless at gmail.com>
> # Date 1290278508 -7200
> # Node ID 6e86bfe8f7236dcd5ff3a95fa47bc553c03e4fd2
> # Parent  42ac864ed3946df2a3b7b87dcbc05cd4d35a62c3
> revert: improve merge advice and favor its error over all

This sounds like two distinct changes -- perhaps it should be two
separate patches.

> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -3105,14 +3105,15 @@ def revert(ui, repo, *pats, **opts):
>             raise util.Abort(_("you can't specify a revision and a date"))
>         opts["rev"] = cmdutil.finddate(ui, repo, opts["date"])
>
> +    parent, p2 = repo.dirstate.parents()
> +    if not opts.get('rev') and p2 != nullid:
> +        raise util.Abort(_('uncommitted merge - '
> +                           'use hg up, see "hg help revert"'))
> +
>     if not pats and not opts.get('all'):
>         raise util.Abort(_('no files or directories specified; '
>                            'use --all to revert the whole repo'))
>
> -    parent, p2 = repo.dirstate.parents()
> -    if not opts.get('rev') and p2 != nullid:
> -        raise util.Abort(_('uncommitted merge - please provide a '
> -                           'specific revision'))

In particular, moving this check up seems harmless to me, but I don't
see the point.  If you run plain "hg revert" during a merge, you have
two problems.  You need to supply files (or -a) and you need to
specify a revision to revert to.  Absent a framework for accumulating
errors and reporting them all in one go, I don't see how to avoid
making the user suffer through two aborts, one for each problem.  Why
does it matter which one they get first?

As for changing the error message itself: what use case are you trying
to address?  The use case addressed by the current message is, "I want
to commit this merge, but I need to force foo.c to the version in the
first (second) parent".  E.g. "hg revert -r . --all" is one way to do
a dummy merge, and that's what the existing error hints at.

Suggesting "hg update" makes it sound like you're concerned with a
completely different use case.  Which?

Greg


More information about the Mercurial-devel mailing list