--- a/mercurial/hgweb/webcommands.py Tue Nov 01 14:12:39 2016 -0400
+++ b/mercurial/hgweb/webcommands.py Sat Nov 05 09:38:07 2016 -0700
@@ -861,12 +861,24 @@
f = fctx.path()
parity = paritygen(web.stripecount)
+ # parents() is called once per line and several lines likely belong to
+ # same revision. So it is worth caching.
+ # TODO there are still redundant operations within basefilectx.parents()
+ # and from the fctx.annotate() call itself that could be cached.
+ parentscache = {}
def parents(f):
- for p in f.parents():
- yield {
- "node": p.hex(),
- "rev": p.rev(),
- }
+ rev = f.rev()
+ if rev not in parentscache:
+ parentscache[rev] = []
+ for p in f.parents():
+ entry = {
+ 'node': p.hex(),
+ 'rev': p.rev(),
+ }
+ parentscache[rev].append(entry)
+
+ for p in parentscache[rev]:
+ yield p
def annotate(**map):
if util.binary(fctx.data()):