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 @@ -6,7 +6,7 @@ # This software may be used and distributed according to the terms of the # GNU General Public License version 2 or any later version. -import os, re +import os from mercurial import ui, hg, hook, error, encoding, templater, util, repoview from mercurial.templatefilters import websub from mercurial.i18n import _ @@ -60,7 +60,6 @@ def makebreadcrumb(url, prefix=''): urlel = os.path.dirname(urlel) return reversed(breadcrumb) - class requestcontext(object): """Holds state/context for an individual request. @@ -163,7 +162,7 @@ class hgweb(object): # web.templates in .hg/hgrc to get access to any file readable # by the user running the CGI script self.templatepath = self.config('web', 'templates', untrusted=False) - self.websubtable = self.loadwebsub() + self.websubtable = webutil.getwebsubs(r) # The CGI scripts are often run by a user different from the repo owner. # Trust the settings from the .hg/hgrc files by default. @@ -369,47 +368,6 @@ class hgweb(object): return [''] return tmpl('error', error=inst.message) - def loadwebsub(self): - websubtable = [] - websubdefs = self.repo.ui.configitems('websub') - # we must maintain interhg backwards compatibility - websubdefs += self.repo.ui.configitems('interhg') - for key, pattern in websubdefs: - # grab the delimiter from the character after the "s" - unesc = pattern[1] - delim = re.escape(unesc) - - # identify portions of the pattern, taking care to avoid escaped - # delimiters. the replace format and flags are optional, but - # delimiters are required. - match = re.match( - r'^s%s(.+)(?:(?<=\\\\)|(?