D6146: discovery: prevent deleting items from a dictionary

pulkit (Pulkit Goyal) phabricator at mercurial-scm.org
Wed Mar 27 15:37:02 EDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rHG0cc9d7918754: discovery: prevent deleting items from a dictionary (authored by pulkit, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6146?vs=14538&id=14601

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

AFFECTED FILES
  mercurial/discovery.py

CHANGE DETAILS

diff --git a/mercurial/discovery.py b/mercurial/discovery.py
--- a/mercurial/discovery.py
+++ b/mercurial/discovery.py
@@ -212,10 +212,11 @@
     with remote.commandexecutor() as e:
         remotemap = e.callcommand('branchmap', {}).result()
 
-    remotebranches = set(remotemap)
-
-    # A. register remote heads
+    # A. register remote heads of branches which are in outgoing set
     for branch, heads in remotemap.iteritems():
+        # don't add head info about branches which we don't have locally
+        if branch not in branches:
+            continue
         known = []
         unsynced = []
         knownnode = cl.hasnode # do not use nodemap until it is filtered
@@ -225,16 +226,13 @@
             else:
                 unsynced.append(h)
         headssum[branch] = (known, list(known), unsynced)
+
     # B. add new branch data
     for branch in branches:
         if branch not in headssum:
             headssum[branch] = (None, [], [])
 
-    # C drop data about untouched branches:
-    for branch in remotebranches - branches:
-        del headssum[branch]
-
-    # D. Update newmap with outgoing changes.
+    # C. Update newmap with outgoing changes.
     # This will possibly add new heads and remove existing ones.
     newmap = branchmap.remotebranchcache((branch, heads[1])
                                  for branch, heads in headssum.iteritems()



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


More information about the Mercurial-devel mailing list