discovery: simplify branchmap construction against legacy server
All necessary data to fire a simple revset query are already known. No call to
ancestors are needed. Such ancestors calculation was already done to compute
outgoing.missing.
--- a/mercurial/discovery.py Wed Jun 27 13:41:04 2012 -0500
+++ b/mercurial/discovery.py Fri Jun 22 12:17:49 2012 +0200
@@ -207,18 +207,16 @@
# 1-4b. old servers: Check for new topological heads.
# Construct {old,new}map with branch = None (topological branch).
# (code based on _updatebranchcache)
- 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
- reachable = cl.ancestors([latest], min(newheadrevs))
- newheadrevs.difference_update(reachable)
+ oldheads = set(h for h in remoteheads if h in cl.nodemap)
+ # all nodes in outgoing.missing are children of either:
+ # - an element of oldheads
+ # - another element of outgoing.missing
+ # - nullrev
+ # This explains why the new head are very simple to compute.
+ r = repo.set('heads(%ln + %ln)', oldheads, outgoing.missing)
branches = set([None])
- newmap = {None: [cl.node(rev) for rev in newheadrevs]}
- oldmap = {None: [cl.node(rev) for rev in oldheadrevs]}
+ newmap = {None: list(c.node() for c in r)}
+ oldmap = {None: oldheads}
unsynced = inc and branches or set()
# 5. Check for new heads.