[PATCH STABLE v2] hgwebdir: reduce memory usage for index generation

Wagner Bruna wagner.bruna+mercurial at gmail.com
Thu Feb 17 17:27:25 CST 2011

# HG changeset patch
# User Wagner Bruna <wbruna at softwareexpress.com.br>
# Date 1297973127 7200
# Branch stable
# Node ID 2e837df9cc719a3a3ae9c38c5c4d9a0929866f18
# Parent  e71af93f6d630c952dd8eb9519c76333b520f12a
hgwebdir: reduce memory usage for index generation

The archive list generator was holding a reference to each
temporary ui copy passed by rawentries(), so the memory
usage for index generation growed proportionally to the
ui object size and the amount of repositories. By returning a
list instead, the temporary reference is dropped immediately.

diff --git a/mercurial/hgweb/hgwebdir_mod.py b/mercurial/hgweb/hgwebdir_mod.py
--- a/mercurial/hgweb/hgwebdir_mod.py
+++ b/mercurial/hgweb/hgwebdir_mod.py
@@ -203,11 +203,13 @@ class hgwebdir(object):
         def archivelist(ui, nodeid, url):
             allowed = ui.configlist("web", "allow_archive", untrusted=True)
+            archives = []
             for i in [('zip', '.zip'), ('gz', '.tar.gz'), ('bz2', '.tar.bz2')]:
                 if i[0] in allowed or ui.configbool("web", "allow" + i[0],
-                    yield {"type" : i[0], "extension": i[1],
-                           "node": nodeid, "url": url}
+                    archives.append({"type" : i[0], "extension": i[1],
+                                     "node": nodeid, "url": url})
+            return archives
         def rawentries(subdir="", **map):

More information about the Mercurial-devel mailing list