diff mercurial/commands.py @ 9097:431462bd8478

fix memory usage of revlog caches by limiting cache size [issue1639]
author Matt Mackall <mpm@selenic.com>
date Thu, 09 Jul 2009 17:10:07 -0500
parents 7b19cda0fa10
children bbc78cb1bf15 98d90ad54749
line wrap: on
line diff
--- a/mercurial/commands.py	Thu Jul 09 11:59:12 2009 +0200
+++ b/mercurial/commands.py	Thu Jul 09 17:10:07 2009 -0500
@@ -1206,18 +1206,7 @@
     if opts.get('print0'):
         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]
+    getfile = util.lrucachefunc(repo.file)
 
     def matchlines(body):
         begin = 0