diff --git a/mercurial/discovery.py b/mercurial/discovery.py --- a/mercurial/discovery.py +++ b/mercurial/discovery.py @@ -21,6 +21,7 @@ from . import ( branchmap, error, phases, + scmutil, setdiscovery, treediscovery, util, @@ -365,11 +366,8 @@ def checkheads(pushop): if None in unsyncedheads: # old remote, no heads data heads = None - elif len(unsyncedheads) <= 4 or repo.ui.verbose: - heads = ' '.join(short(h) for h in unsyncedheads) else: - heads = (' '.join(short(h) for h in unsyncedheads[:4]) + - ' ' + _("and %s others") % (len(unsyncedheads) - 4)) + heads = scmutil.nodesummaries(repo, unsyncedheads) if heads is None: repo.ui.status(_("remote has heads that are " "not known locally\n")) diff --git a/mercurial/scmutil.py b/mercurial/scmutil.py --- a/mercurial/scmutil.py +++ b/mercurial/scmutil.py @@ -1280,6 +1280,12 @@ def registersummarycallback(repo, otr, t revrange = '%s:%s' % (minrev, maxrev) repo.ui.status(_('new changesets %s\n') % revrange) +def nodesummaries(repo, nodes, maxnumnodes=4): + if len(nodes) <= maxnumnodes or repo.ui.verbose: + return ' '.join(short(h) for h in nodes) + first = ' '.join(short(h) for h in nodes[:maxnumnodes]) + return _("%s and %s others") % (first, len(nodes) - maxnumnodes) + def wrapconvertsink(sink): """Allow extensions to wrap the sink returned by convcmd.convertsink() before it is used, whether or not the convert extension was formally loaded.