# HG changeset patch # User Brendan Cully # Date 1247615512 25200 # Node ID 6d1f9238824e5ad61430fdbc303370ff696ed0b4 # Parent 5e5a91e39642c246542dc9d1f03c7fa8ada0bbd3# Parent 360f61c2919f58840d05ae88388c5d9ffbac9597 Merge with crew-stable diff -r 5e5a91e39642 -r 6d1f9238824e mercurial/patch.py --- a/mercurial/patch.py Wed Jul 15 00:24:20 2009 +0200 +++ b/mercurial/patch.py Tue Jul 14 16:51:52 2009 -0700 @@ -1242,12 +1242,21 @@ if not node1: node1 = repo.dirstate.parents()[0] - flcache = {} - def getfilectx(f, ctx): - flctx = ctx.filectx(f, filelog=flcache.get(f)) - if f not in flcache: - flcache[f] = flctx._filelog - return flctx + def lrugetfilectx(): + cache = {} + order = [] + def getfilectx(f, ctx): + fctx = ctx.filectx(f, filelog=cache.get(f)) + if f not in cache: + if len(cache) > 20: + del cache[order.pop(0)] + cache[f] = fctx._filelog + else: + order.remove(f) + order.append(f) + return fctx + return getfilectx + getfilectx = lrugetfilectx() ctx1 = repo[node1] ctx2 = repo[node2]