[PATCH] merge: when current branch has 1 or > 2 heads, actually abort

Martin Geisler mg at lazybytes.net
Mon Jun 14 17:06:09 CDT 2010


Greg Ward <greg-hg at gerg.ca> writes:

> # HG changeset patch
> # User Greg Ward <greg-hg at gerg.ca>
> # Date 1276546012 14400
> # Node ID 7422ede2bda7c8a786c4f0d1f1e5138219423b95
> # Parent  c6971a790206f824df9b25607fa4d030baad92fd
> merge: when current branch has 1 or > 2 heads, actually abort.
>
> Currently merge just prints abort-like messages to stderr and then
> exits with a misleading status 0 (cleverly disguised as "False").
> With this change it raises Abort, just like every other fatal error.
>
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -2561,19 +2561,20 @@
>          branch = repo.changectx(None).branch()
>          bheads = repo.branchheads(branch)
>          if len(bheads) > 2:
> -            ui.warn(_("abort: branch '%s' has %d heads - "
> -                      "please merge with an explicit rev\n")
> -                    % (branch, len(bheads)))
> -            ui.status(_("(run 'hg heads .' to see heads)\n"))
> -            return False
> +            raise util.Abort(_(
> +                'branch \'%s\' has %d heads - '
> +                'please merge with an explicit rev\n'
> +                '(run \'hg heads .\' to see heads)')
> +                % (branch, len(bheads)))

Why do you change the quotes from double to single quotes? I prefre
double quotes to begin with, especially when they lets us avoid quoting
single quotes.

-- 
Martin Geisler

See my Mercurial presentation: http://vimeo.com/11497288
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20100615/50cbd3c5/attachment.pgp>


More information about the Mercurial-devel mailing list