grep: make cache LRU rather than unlimited
grep could cache an unbounded number of revlogs, limit to 20 with an
LRU cache.
--- a/mercurial/commands.py Thu May 14 13:20:40 2009 -0500
+++ b/mercurial/commands.py Thu May 14 13:20:40 2009 -0500
@@ -1154,9 +1154,16 @@
sep = eol = '\0'
fcache = {}
+ forder = []
def getfile(fn):
if fn not in fcache:
+ if len(fcache) > 20:
+ del fcache[forder.pop(0)]
fcache[fn] = repo.file(fn)
+ else:
+ forder.remove(fn)
+
+ forder.append(fn)
return fcache[fn]
def matchlines(body):