[PATCH 2 of 2 STABLE] merge: improve error detection and reporting
Matt Mackall
mpm at selenic.com
Mon May 3 16:00:48 CDT 2010
On Sun, 2010-05-02 at 10:48 -0400, Greg Ward wrote:
> # HG changeset patch
> # User Greg Ward <greg-hg at gerg.ca>
> # Date 1272811643 14400
> # Branch stable
> # Node ID 89413f695c67fc7c03814ce94dba480773c8cfde
> # Parent b344ddac6247c92150da4187b3365ab2f2442abd
> merge: improve error detection and reporting.
> - make hg exit with non-zero status when branch has 1 or >2 heads
> - tweak the error messages for those cases
> - add explicit detection of merging current changeset with itself
> - rewrite messages for attempting to merge with ancestor or descendant
> of current changeset
This could probably be a few separate changes for clarity.
> diff --git a/mercurial/commands.py b/mercurial/commands.py
> --- a/mercurial/commands.py
> +++ b/mercurial/commands.py
> @@ -2225,19 +2225,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 explicit rev\n'
> + '(run "hg heads %s" to see all branch heads)')
> + % (branch, len(bheads), branch))
a) Why is the warn changing to an abort? Is this a workaround for the
-caller- failing to propagate an error code?
b) Why is the quoting changing?
> parent = repo.dirstate.parents()[0]
> if len(bheads) == 1:
> if len(repo.heads()) > 1:
> - ui.warn(_("abort: branch '%s' has one head - "
> - "please merge with an explicit rev\n" % branch))
> - ui.status(_("(run 'hg heads' to see all heads)\n"))
> - return False
> + raise util.Abort(_(
> + 'branch \'%s\' has one head -- '
> + 'please merge with explicit rev\n'
> + '(run "hg heads -t" to see all repository heads)')
> + % branch)
Same here.
> msg = _('there is nothing to merge')
> if parent != repo.lookup(repo[None].branch()):
> msg = _('%s - use "hg update" instead') % msg
> diff --git a/mercurial/merge.py b/mercurial/merge.py
> --- a/mercurial/merge.py
> +++ b/mercurial/merge.py
> @@ -408,7 +408,7 @@
>
> def update(repo, node, branchmerge, force, partial):
> """
> - Perform a merge between the working directory and the given node
> + Perform a merge between the working directory and the given node.
Unrelated change..?
--
Mathematics is the supreme nostalgia of our time.
More information about the Mercurial-devel
mailing list