# HG changeset patch # User Gregory Szorc # Date 1478050083 25200 # Node ID d92777f9852424b2acde9c487cd6f8eedf24e9b1 # Parent 730c7fc8889aed019110c1b10bfe2908dfff849f changegroup: cache changelog and manifestlog outside of loop History has taught us that repo.changelog can add significant overhead to loops. So cache the changelog instance outside of the loop to avoid the lookup. While we're here, do the same for manifestlog, since each loop would otherwise initialize a new manifestlog instance. diff -r 730c7fc8889a -r d92777f98524 mercurial/changegroup.py --- a/mercurial/changegroup.py Tue Nov 01 18:49:23 2016 -0700 +++ b/mercurial/changegroup.py Tue Nov 01 18:28:03 2016 -0700 @@ -330,11 +330,12 @@ needfiles = {} if repo.ui.configbool('server', 'validate', default=False): + cl = repo.changelog + ml = repo.manifestlog # validate incoming csets have their manifests for cset in xrange(clstart, clend): - mfnode = repo.changelog.read( - repo.changelog.node(cset))[0] - mfest = repo.manifestlog[mfnode].readdelta() + mfnode = cl.read(cl.node(cset))[0] + mfest = ml[mfnode].readdelta() # store file nodes we must see for f, n in mfest.iteritems(): needfiles.setdefault(f, set()).add(n)