mercurial/discovery.py
changeset 17011 25f7d40fe735
parent 17009 0c18aed2fcca
child 17043 6f89c3f0192d
--- a/mercurial/discovery.py	Fri Jun 08 14:21:32 2012 -0700
+++ b/mercurial/discovery.py	Fri Jun 08 14:23:31 2012 -0700
@@ -207,19 +207,18 @@
         # 1-4b. old servers: Check for new topological heads.
         # Construct {old,new}map with branch = None (topological branch).
         # (code based on _updatebranchcache)
-        oldheads = set(h for h in remoteheads if h in cl.nodemap)
-        newheads = oldheads.union(outgoing.missing)
-        if len(newheads) > 1:
-            for latest in reversed(outgoing.missing):
-                if latest not in newheads:
+        oldheadrevs = set(cl.rev(h) for h in remoteheads if h in cl.nodemap)
+        missingrevs = [cl.rev(node) for node in outgoing.missing]
+        newheadrevs = oldheadrevs.union(missingrevs)
+        if len(newheadrevs) > 1:
+            for latest in sorted(missingrevs, reverse=True):
+                if latest not in newheadrevs:
                     continue
-                minhrev = min(cl.rev(h) for h in newheads)
-                reachable = [cl.node(rev) for rev in
-                             cl.ancestors([cl.rev(latest)], minhrev)]
-                newheads.difference_update(reachable)
+                reachable = cl.ancestors([latest], min(newheadrevs))
+                newheadrevs.difference_update(reachable)
         branches = set([None])
-        newmap = {None: newheads}
-        oldmap = {None: oldheads}
+        newmap = {None: [cl.node(rev) for rev in newheadrevs]}
+        oldmap = {None: [cl.node(rev) for rev in oldheadrevs]}
         unsynced = inc and branches or set()
 
     # 5. Check for new heads.