[PATCH] merge: abort if picked revision is bookmarked

Martin Geisler martin at geisler.net
Tue May 15 03:47:33 CDT 2012


David Soria Parra <dsp at php.net> writes:

> # HG changeset patch
> # User David Soria Parra <dsp at php.net>
> # Date 1336820911 -7200
> # Branch stable
> # Node ID 08a06bbfcdef8a72b8bfab61dda5c1290025c7d8
> # Parent  f6a973bc0f0249aebeeca12135ac9c6d45dcdfb6
> merge: abort if picked revision is bookmarked
>
> Users can accidentally merge a bookmark if they pull and blindly type
> merge. We assume that bookmarked heads are similar to named branches
> and should only merged be merged explicitly.
>
> We are aborting a merge if one of the automatically picked revisions
> is bookmarked. In case we only have diverged bookmarks, we go ahead
> and merge those.
>
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -4148,6 +4148,12 @@
>                               hint=_("use 'hg update' or merge with an "
>                                      "explicit revision"))
>          node = parent == bheads[0] and bheads[-1] or bheads[0]
> +        p1marks = [b.split('@', 1)[0] for b in repo['.'].bookmarks()]
> +        p2marks = [b.split('@', 1)[0] for b in repo[node].bookmarks()]
> +        if set(p1marks) ^ set(p2marks):
> +            raise util.Abort(_("head is bookmarked - "
> +                             "please merge with an explicit rev"),
> +                             hint=_("run 'hg heads' to see all heads"))

I agree with the functionality, but I think the error message could be
better. I don't think it's clear from the message which head is
bookmarked -- my head or the one I didn't specify on the command line :)

When there is one one branch head, you're told:

  abort: branch 'foo' has one head - please merge with an explicit rev
  (run 'hg heads' to see all heads)

I think we can almost use the same message here, especially if we change
"one head" to "one anonymous head"? That unfortunately introduces new
terminology, so users might have to look up what an "anonymous head" is
in 'hg help glossary'.

-- 
Martin Geisler

aragost Trifork
Commercial Mercurial support
http://aragost.com/mercurial/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20120515/7456fb62/attachment.pgp>


More information about the Mercurial-devel mailing list