diff -r 8d14d91584f1 -r 5997eabc7b85 mercurial/discovery.py --- a/mercurial/discovery.py Tue Apr 16 02:06:20 2019 +0530 +++ b/mercurial/discovery.py Fri Mar 01 05:56:18 2019 +0530 @@ -340,13 +340,22 @@ pushop.pushbranchmap = headssum newbranches = [branch for branch, heads in headssum.iteritems() if heads[0] is None] + # Makes a set of closed branches + closedbranches = set() + for tag, heads, tip, isclosed in repo.branchmap().iterbranches(): + if isclosed: + closedbranches.add(tag) + closedbranches = (closedbranches & set(newbranches)) # 1. Check for new branches on the remote. if newbranches and not newbranch: # new branch requires --new-branch branchnames = ', '.join(sorted(newbranches)) - raise error.Abort(_("push creates new remote branches: %s!") - % branchnames, - hint=_("use 'hg push --new-branch' to create" - " new remote branches")) + if closedbranches: + errmsg = (_("push creates new remote branches: %s (%d closed)!") + % (branchnames, len(closedbranches))) + else: + errmsg = (_("push creates new remote branches: %s!")% branchnames) + hint=_("use 'hg push --new-branch' to create new remote branches") + raise error.Abort(errmsg, hint=hint) # 2. Find heads that we need not warn about nowarnheads = _nowarnheads(pushop)