[PATCH] hgweb: load extensions explicitly (issue1824)

Yuya Nishihara yuya at tcha.org
Wed Oct 28 10:17:39 CDT 2009


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1256742908 -32400
# Node ID bda617e9df583a8adb4380acc98f8d2ca4e548d5
# Parent  ccf1bfe1806de0789b815b1ad4ac22dbaac95ae3
hgweb: load extensions explicitly (issue1824)

previously extensions.loadall() was called indirectly
by hg.repository(), so extsetup() never called.

this changes hgweb to load extensions explicitly and
to invoke extsetup().

diff --git a/mercurial/hgweb/hgweb_mod.py b/mercurial/hgweb/hgweb_mod.py
--- a/mercurial/hgweb/hgweb_mod.py
+++ b/mercurial/hgweb/hgweb_mod.py
@@ -7,7 +7,7 @@
 # GNU General Public License version 2, incorporated herein by reference.
 
 import os
-from mercurial import ui, hg, hook, error, encoding, templater
+from mercurial import ui, hg, hook, error, encoding, templater, extensions
 from common import get_mtime, ErrorResponse
 from common import HTTP_OK, HTTP_BAD_REQUEST, HTTP_NOT_FOUND, HTTP_SERVER_ERROR
 from common import HTTP_UNAUTHORIZED, HTTP_METHOD_NOT_ALLOWED
@@ -27,6 +27,20 @@ class hgweb(object):
             u = ui.ui()
             u.setconfig('ui', 'report_untrusted', 'off')
             u.setconfig('ui', 'interactive', 'off')
+
+            # load extensions explicitly
+            u.readconfig(os.path.join(repo, '.hg', 'hgrc'))
+            extensions.loadall(u)
+            for name, module in extensions.extensions():
+                extsetup = getattr(module, 'extsetup', None)
+                if extsetup:
+                    try:
+                        extsetup(ui)
+                    except TypeError:
+                        if extsetup.func_code.co_argcount != 0:
+                            raise
+                        extsetup() # old extsetup with no ui argument
+
             self.repo = hg.repository(u, repo)
         else:
             self.repo = repo


More information about the Mercurial-devel mailing list