diff 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
line wrap: on
line diff
--- 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,