Patchwork D6314: discovery: only calculate closed branches if required

login
register
mail settings
Submitter phabricator
Date April 29, 2019, 11:36 p.m.
Message ID <d8c4fcc7764a33203e4cc48bd57485ed@localhost.localdomain>
Download mbox | patch
Permalink /patch/39902/
State Not Applicable
Headers show

Comments

phabricator - April 29, 2019, 11:36 p.m.
This revision was automatically updated to reflect the committed changes.
Closed by commit rHGd0e773ad9077: discovery: only calculate closed branches if required (authored by pulkit, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6314?vs=14931&id=14973

REVISION DETAIL
  https://phab.mercurial-scm.org/D6314

AFFECTED FILES
  mercurial/discovery.py

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/discovery.py b/mercurial/discovery.py
--- 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[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)))