D6314: discovery: only calculate closed branches if required
pulkit (Pulkit Goyal)
phabricator at mercurial-scm.org
Sat Apr 27 07:44:24 EDT 2019
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.
The number of new closed branches is required for printing in error message. So
let's only calculate them if we need to print error about new branches.
diff --git a/mercurial/discovery.py b/mercurial/discovery.py
@@ -340,15 +340,15 @@
pushop.pushbranchmap = headssum
newbranches = [branch for branch, heads in headssum.iteritems()
if heads is None]
- # Makes a set of closed branches
- closedbranches = set()
- for tag, heads, tip, isclosed in repo.branchmap().iterbranches():
- if isclosed:
- 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))
+ # Calculate how many of the new branches are closed branches
+ closedbranches = set()
+ for tag, heads, tip, isclosed in repo.branchmap().iterbranches():
+ if isclosed:
+ closedbranches = (closedbranches & set(newbranches))
errmsg = (_("push creates new remote branches: %s (%d closed)!")
% (branchnames, len(closedbranches)))
To: pulkit, #hg-reviewers
More information about the Mercurial-devel