diff mercurial/discovery.py @ 20225:d2704c48f417

discovery: stop using nodemap for membership testing Nodemap is not aware of filtering so we need to ask the changelog itself if a node is known. This is probably a bit slower but such check does not dominated discovery time. This is necessary if we want to run discovery on filtered repo.
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Fri, 15 Nov 2013 23:28:43 -0500
parents a14d93b2fb1b
children fff0a71f8177
line wrap: on
line diff
--- a/mercurial/discovery.py	Fri Nov 15 23:27:39 2013 -0500
+++ b/mercurial/discovery.py	Fri Nov 15 23:28:43 2013 -0500
@@ -34,9 +34,9 @@
 
     if heads:
         allknown = True
-        nm = repo.changelog.nodemap
+        knownnode = repo.changelog.hasnode # no nodemap until it is filtered
         for h in heads:
-            if nm.get(h) is None:
+            if not knownnode(h):
                 allknown = False
                 break
         if allknown:
@@ -172,8 +172,9 @@
         remotebranches.add(branch)
         known = []
         unsynced = []
+        knownnode = cl.hasnode # do not use nodemap until it is filtered
         for h in heads:
-            if h in cl.nodemap:
+            if knownnode(h):
                 known.append(h)
             else:
                 unsynced.append(h)
@@ -204,11 +205,11 @@
 def _oldheadssummary(repo, remoteheads, outgoing, inc=False):
     """Compute branchmapsummary for repo without branchmap support"""
 
-    cl = repo.changelog
     # 1-4b. old servers: Check for new topological heads.
     # Construct {old,new}map with branch = None (topological branch).
     # (code based on update)
-    oldheads = set(h for h in remoteheads if h in cl.nodemap)
+    knownnode = repo.changelog.hasnode # no nodemap until it is filtered
+    oldheads = set(h for h in remoteheads if knownnode(h))
     # all nodes in outgoing.missing are children of either:
     # - an element of oldheads
     # - another element of outgoing.missing