Mercurial > hg
changeset 42216:d0e773ad9077
discovery: only calculate closed branches if required
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.
Differential Revision: https://phab.mercurial-scm.org/D6314
author | Pulkit Goyal <pulkit@yandex-team.ru> |
---|---|
date | Sat, 27 Apr 2019 14:43:43 +0300 |
parents | 9893d7aa7420 |
children | ca762c2bbe6b |
files | mercurial/discovery.py |
diffstat | 1 files changed, 6 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/discovery.py Sat Apr 27 02:13:43 2019 +0300 +++ b/mercurial/discovery.py Sat Apr 27 14:43:43 2019 +0300 @@ -340,15 +340,15 @@ 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)) + # Calculate how many of the new branches are closed branches + closedbranches = set() + for tag, heads, tip, isclosed in repo.branchmap().iterbranches(): + if isclosed: + closedbranches.add(tag) + closedbranches = (closedbranches & set(newbranches)) if closedbranches: errmsg = (_("push creates new remote branches: %s (%d closed)!") % (branchnames, len(closedbranches)))