Commit 9f62ebe9 authored by Matt Harbison's avatar Matt Harbison
Browse files

discovery: list the new heads like core does when failing a multi-head push

The message was, and still is slightly different from core (which mentions
'remote' heads).  But it's probably useful to have slightly different messages
so that we can easily determine the source.
parent cc0f46025c7f
Pipeline #11506 failed with stage
in 3 minutes and 55 seconds
......@@ -10,6 +10,7 @@ from mercurial import (
error,
exchange,
extensions,
scmutil,
util,
)
from . import (
......@@ -186,7 +187,7 @@ def _nbheads(repo):
continue
oldheads = [repo[n].rev() for n in b[1]]
newheads = _filter_obsolete_heads(repo, oldheads)
data[b[0]] = len(newheads)
data[b[0]] = newheads
return data
def handlecheckheads(orig, op, inpart):
......@@ -211,14 +212,24 @@ def handlecheckheads(orig, op, inpart):
repo.invalidatecaches()
finalheads = _nbheads(repo)
for branch, oldnb in tr._prepushheads.items():
newnb = finalheads.pop(branch, 0)
if oldnb < newnb:
msg = _(b"push creates a new head on branch '%s'" % branch)
newheads = finalheads.pop(branch, [])
if len(oldnb) < len(newheads):
cl = repo.changelog
newheads = sorted(set(newheads).difference(oldnb))
heads = scmutil.nodesummaries(repo, [cl.node(r) for r in newheads])
msg = _(
b"push creates new heads on branch '%s': %s"
% (branch, heads)
)
raise error.Abort(msg)
for branch, newnb in finalheads.items():
if 1 < newnb:
msg = _(b"push creates new branch '%s' with multiple heads"
% branch)
if 1 < len(newnb):
cl = repo.changelog
heads = scmutil.nodesummaries(repo, [cl.node(r) for r in newnb])
msg = _(
b"push creates new branch '%s' with multiple heads: %s"
% (branch, heads)
)
hint = _(b"merge or see 'hg help push' for details about "
b"pushing new heads")
raise error.Abort(msg, hint=hint)
......
......@@ -508,5 +508,5 @@ Pushing should complain because it would create two heads on default
pushing to repoB
searching for changes
no changes found
abort: push creates a new head on branch 'default'
abort: push creates new heads on branch 'default': bbd9d6199b88
[255]
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment