# HG changeset patch # User Pulkit Goyal # Date 1552836563 -10800 # Node ID 98908e36d58ad25449474efb9ffd66fb209b10de # Parent 66fc05ff0ea3914e70a77910cc17fb768aa21fd6 discovery: prevent recomputing info about server and outgoing changesets We already iterate over the outgoing.missing above and lookup repo for them. So let's reuse info calculated at that time instead of recomputing that again. Also we calculate the set of remotebranches by doing set(remotemap), so let's reuse that again. Upcoming patches will clean things a bit more. Differential Revision: https://phab.mercurial-scm.org/D6144 diff -r 66fc05ff0ea3 -r 98908e36d58a mercurial/discovery.py --- a/mercurial/discovery.py Thu Mar 21 21:44:29 2019 +0100 +++ b/mercurial/discovery.py Sun Mar 17 18:29:23 2019 +0300 @@ -201,19 +201,24 @@ outgoing = pushop.outgoing cl = repo.changelog headssum = {} + missingctx = set() # A. Create set of branches involved in the push. - branches = set(repo[n].branch() for n in outgoing.missing) + branches = set() + for n in outgoing.missing: + ctx = repo[n] + missingctx.add(ctx) + branches.add(ctx.branch()) + nbranches = branches.copy() with remote.commandexecutor() as e: remotemap = e.callcommand('branchmap', {}).result() - newbranches = branches - set(remotemap) + remotebranches = set(remotemap) + newbranches = branches - remotebranches branches.difference_update(newbranches) # A. register remote heads - remotebranches = set() for branch, heads in remotemap.iteritems(): - remotebranches.add(branch) known = [] unsynced = [] knownnode = cl.hasnode # do not use nodemap until it is filtered @@ -224,16 +229,12 @@ unsynced.append(h) headssum[branch] = (known, list(known), unsynced) # B. add new branch data - missingctx = list(repo[n] for n in outgoing.missing) - touchedbranches = set() - for ctx in missingctx: - branch = ctx.branch() - touchedbranches.add(branch) + for branch in nbranches: if branch not in headssum: headssum[branch] = (None, [], []) # C drop data about untouched branches: - for branch in remotebranches - touchedbranches: + for branch in remotebranches - nbranches: del headssum[branch] # D. Update newmap with outgoing changes.