comparison hgext/censor.py @ 39615:a658f97c1ce4

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
author Valentin Gatien-Baron <vgatien-baron@janestreet.com>
date Thu, 13 Sep 2018 16:22:53 -0400
parents e7aa113b14f7
children 8bfbb25859f1
comparison
equal deleted inserted replaced
39614:a2880ac67ee0 39615:a658f97c1ce4
81 fctx = ctx.filectx(path) 81 fctx = ctx.filectx(path)
82 except error.LookupError: 82 except error.LookupError:
83 raise error.Abort(_('file does not exist at revision %s') % rev) 83 raise error.Abort(_('file does not exist at revision %s') % rev)
84 84
85 fnode = fctx.filenode() 85 fnode = fctx.filenode()
86 headctxs = [repo[c] for c in repo.heads()] 86 heads = []
87 heads = [c for c in headctxs if path in c and c.filenode(path) == fnode] 87 for headnode in repo.heads():
88 c = repo[headnode]
89 if path in c and c.filenode(path) == fnode:
90 heads.append(c)
88 if heads: 91 if heads:
89 headlist = ', '.join([short(c.node()) for c in heads]) 92 headlist = ', '.join([short(c.node()) for c in heads])
90 raise error.Abort(_('cannot censor file in heads (%s)') % headlist, 93 raise error.Abort(_('cannot censor file in heads (%s)') % headlist,
91 hint=_('clean/delete and commit first')) 94 hint=_('clean/delete and commit first'))
92 95