Mercurial > hg
comparison mercurial/patch.py @ 9123:360f61c2919f
Make patch.diff filelog cache LRU of 20 files. Fixes issue1738.
20 files is as fast as 200 for hg diff -r 28015:30103 of mozilla-central.
Ideally we'd use util.lrucachefunc, but the interface doesn't quite work.
author | Brendan Cully <brendan@kublai.com> |
---|---|
date | Tue, 14 Jul 2009 16:50:37 -0700 |
parents | 5fe8dc75aa4a |
children | 6d1f9238824e df21a009c9c4 |
comparison
equal
deleted
inserted
replaced
9122:a9eae2f3241c | 9123:360f61c2919f |
---|---|
1244 opts = mdiff.defaultopts | 1244 opts = mdiff.defaultopts |
1245 | 1245 |
1246 if not node1: | 1246 if not node1: |
1247 node1 = repo.dirstate.parents()[0] | 1247 node1 = repo.dirstate.parents()[0] |
1248 | 1248 |
1249 flcache = {} | 1249 def lrugetfilectx(): |
1250 def getfilectx(f, ctx): | 1250 cache = {} |
1251 flctx = ctx.filectx(f, filelog=flcache.get(f)) | 1251 order = [] |
1252 if f not in flcache: | 1252 def getfilectx(f, ctx): |
1253 flcache[f] = flctx._filelog | 1253 fctx = ctx.filectx(f, filelog=cache.get(f)) |
1254 return flctx | 1254 if f not in cache: |
1255 if len(cache) > 20: | |
1256 del cache[order.pop(0)] | |
1257 cache[f] = fctx._filelog | |
1258 else: | |
1259 order.remove(f) | |
1260 order.append(f) | |
1261 return fctx | |
1262 return getfilectx | |
1263 getfilectx = lrugetfilectx() | |
1255 | 1264 |
1256 ctx1 = repo[node1] | 1265 ctx1 = repo[node1] |
1257 ctx2 = repo[node2] | 1266 ctx2 = repo[node2] |
1258 | 1267 |
1259 if not changes: | 1268 if not changes: |