# HG changeset patch # User Matt Harbison # Date 1600366298 14400 # Node ID 36ccafa690954d4c10f764c87286a3dbac8c2d75 # Parent cc0f46025c7f06ffe26b5623707fae8720bc9b79 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. diff -r cc0f46025c7f -r 36ccafa69095 hgext3rd/topic/discovery.py --- a/hgext3rd/topic/discovery.py Fri Aug 21 18:05:37 2020 +0530 +++ b/hgext3rd/topic/discovery.py Thu Sep 17 14:11:38 2020 -0400 @@ -10,6 +10,7 @@ error, exchange, extensions, + scmutil, util, ) from . import ( @@ -186,7 +187,7 @@ 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 @@ 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) diff -r cc0f46025c7f -r 36ccafa69095 tests/test-topic-push.t --- a/tests/test-topic-push.t Fri Aug 21 18:05:37 2020 +0530 +++ b/tests/test-topic-push.t Thu Sep 17 14:11:38 2020 -0400 @@ -508,5 +508,5 @@ 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]