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.
--- 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)