# HG changeset patch # User Valentin Gatien-Baron # Date 1536870173 14400 # Node ID a658f97c1ce4e26a4642c192dd524da6c3720329 # Parent a2880ac67ee0c497973d69fd7e8bafe22268ce4f censor: use a reasonable amount of memory Before this change, trying to censor some random revision uses an ever increasing amount of memory (I stopped at 20GB, but it was by no means finished), presumably because these contexts have a lot of information that is kept alive. After this change, the memory usage plateaus quickly. Differential Revision: https://phab.mercurial-scm.org/D4582 diff -r a2880ac67ee0 -r a658f97c1ce4 hgext/censor.py --- a/hgext/censor.py Fri Sep 14 22:25:44 2018 +0900 +++ b/hgext/censor.py Thu Sep 13 16:22:53 2018 -0400 @@ -83,8 +83,11 @@ raise error.Abort(_('file does not exist at revision %s') % rev) fnode = fctx.filenode() - headctxs = [repo[c] for c in repo.heads()] - heads = [c for c in headctxs if path in c and c.filenode(path) == fnode] + heads = [] + for headnode in repo.heads(): + c = repo[headnode] + if path in c and c.filenode(path) == fnode: + heads.append(c) if heads: headlist = ', '.join([short(c.node()) for c in heads]) raise error.Abort(_('cannot censor file in heads (%s)') % headlist,