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.
This commit is contained in:
Pierre-Yves David 2012-06-22 12:17:49 +02:00
parent cbbdbdd866
commit d4f8bfb950

View File

@ -207,18 +207,16 @@ def checkheads(repo, remote, outgoing, remoteheads, newbranch=False, inc=False):
# 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.