comparison 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
comparison
equal deleted inserted replaced
9096:47bc92755b95 9097:431462bd8478
1204 return None 1204 return None
1205 sep, eol = ':', '\n' 1205 sep, eol = ':', '\n'
1206 if opts.get('print0'): 1206 if opts.get('print0'):
1207 sep = eol = '\0' 1207 sep = eol = '\0'
1208 1208
1209 fcache = {} 1209 getfile = util.lrucachefunc(repo.file)
1210 forder = []
1211 def getfile(fn):
1212 if fn not in fcache:
1213 if len(fcache) > 20:
1214 del fcache[forder.pop(0)]
1215 fcache[fn] = repo.file(fn)
1216 else:
1217 forder.remove(fn)
1218
1219 forder.append(fn)
1220 return fcache[fn]
1221 1210
1222 def matchlines(body): 1211 def matchlines(body):
1223 begin = 0 1212 begin = 0
1224 linenum = 0 1213 linenum = 0
1225 while True: 1214 while True: