comparison mercurial/changegroup.py @ 30267:d92777f98524

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.
author Gregory Szorc <gregory.szorc@gmail.com>
date Tue, 01 Nov 2016 18:28:03 -0700
parents 260af19891f2
children dc7c4dbc1af9
comparison
equal deleted inserted replaced
30266:730c7fc8889a 30267:d92777f98524
328 repo.ui.status(_("adding manifests\n")) 328 repo.ui.status(_("adding manifests\n"))
329 self._unpackmanifests(repo, revmap, trp, prog, changesets) 329 self._unpackmanifests(repo, revmap, trp, prog, changesets)
330 330
331 needfiles = {} 331 needfiles = {}
332 if repo.ui.configbool('server', 'validate', default=False): 332 if repo.ui.configbool('server', 'validate', default=False):
333 cl = repo.changelog
334 ml = repo.manifestlog
333 # validate incoming csets have their manifests 335 # validate incoming csets have their manifests
334 for cset in xrange(clstart, clend): 336 for cset in xrange(clstart, clend):
335 mfnode = repo.changelog.read( 337 mfnode = cl.read(cl.node(cset))[0]
336 repo.changelog.node(cset))[0] 338 mfest = ml[mfnode].readdelta()
337 mfest = repo.manifestlog[mfnode].readdelta()
338 # store file nodes we must see 339 # store file nodes we must see
339 for f, n in mfest.iteritems(): 340 for f, n in mfest.iteritems():
340 needfiles.setdefault(f, set()).add(n) 341 needfiles.setdefault(f, set()).add(n)
341 342
342 # process the files 343 # process the files