# HG changeset patch # User Matt Mackall # Date 1242325240 18000 # Node ID 72538f1909ecab538f1eaeacaaaf838c3e7d648a # Parent 223000a687b038174fe267e26304990b5ac6599c grep: make cache LRU rather than unlimited grep could cache an unbounded number of revlogs, limit to 20 with an LRU cache. diff -r 223000a687b0 -r 72538f1909ec mercurial/commands.py --- 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):