Patchwork [1,of,3,RESEND] hgweb: load globally-enabled extensions explicitly

login
register
mail settings
Submitter Yuya Nishihara
Date Nov. 24, 2018, 3:41 a.m.
Message ID <2ca38e8c9fe746459607.1543030918@mimosa>
Download mbox | patch
Permalink /patch/36757/
State Accepted
Headers show

Comments

Yuya Nishihara - Nov. 24, 2018, 3:41 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1542449505 -32400
#      Sat Nov 17 19:11:45 2018 +0900
# Node ID 2ca38e8c9fe7464596073de8c6c35a291c1e09c4
# Parent  50a64c321c1e74b98ec1fa959bdc92efdc6f4ee7
hgweb: load globally-enabled extensions explicitly

Before, extensions were loaded as a side effect of hg.repository() if the
hgweb was executed as a CGI/WSGI. I want to make it explicit so that another
ui hook can be inserted after extensions.loadall().

Patch

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
@@ -22,6 +22,7 @@  from .common import (
 from .. import (
     encoding,
     error,
+    extensions,
     formatter,
     hg,
     hook,
@@ -212,6 +213,7 @@  class hgweb(object):
                 u = baseui.copy()
             else:
                 u = uimod.ui.load()
+                extensions.loadall(u)
             r = hg.repository(u, repo)
         else:
             # we trust caller to give us a private copy
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
@@ -30,6 +30,7 @@  from .. import (
     configitems,
     encoding,
     error,
+    extensions,
     hg,
     profiling,
     pycompat,
@@ -268,6 +269,9 @@  class hgwebdir(object):
         self.lastrefresh = 0
         self.motd = None
         self.refresh()
+        if not baseui:
+            # set up environment for new ui
+            extensions.loadall(self.ui)
 
     def refresh(self):
         if self.ui: