# HG changeset patch # User Dirkjan Ochtman # Date 1206379119 -3600 # Node ID a1007f7b9b7b63b311200fbcde78e9eb451ccfdc # Parent 67784cb38d58d882a39e57a1fb26113d84208f58 Backed out changeset d2bb66a8a435 (temporary template compatibility) diff -r 67784cb38d58 -r a1007f7b9b7b mercurial/hgweb/hgweb_mod.py --- a/mercurial/hgweb/hgweb_mod.py Thu Mar 27 12:52:41 2008 -0700 +++ b/mercurial/hgweb/hgweb_mod.py Mon Mar 24 18:18:39 2008 +0100 @@ -6,7 +6,7 @@ # This software may be used and distributed according to the terms # of the GNU General Public License, incorporated herein by reference. -import os, mimetypes, re, mimetools, cStringIO +import os, mimetypes, re from mercurial.node import hex, nullid, short from mercurial.repo import RepoError from mercurial import mdiff, ui, hg, util, archival, patch, hook @@ -226,17 +226,8 @@ try: tmpl = self.templater(req) - try: - ctype = tmpl('mimetype', encoding=self.encoding) - ctype = templater.stringify(ctype) - except KeyError: - # old templates with inline HTTP headers? - if 'mimetype' in tmpl: - raise - header = tmpl('header', encoding=self.encoding) - header_file = cStringIO.StringIO(templater.stringify(header)) - msg = mimetools.Message(header_file, 0) - ctype = msg['content-type'] + ctype = tmpl('mimetype', encoding=self.encoding) + ctype = templater.stringify(ctype) if cmd == '': req.form['cmd'] = [tmpl.cache['default']] @@ -291,13 +282,7 @@ # some functions for the templater def header(**map): - header = tmpl('header', encoding=self.encoding, **map) - if 'mimetype' not in tmpl: - # old template with inline HTTP headers - header_file = cStringIO.StringIO(templater.stringify(header)) - msg = mimetools.Message(header_file, 0) - header = header_file.read() - yield header + yield tmpl('header', encoding=self.encoding, **map) def footer(**map): yield tmpl("footer", **map) diff -r 67784cb38d58 -r a1007f7b9b7b mercurial/hgweb/hgwebdir_mod.py --- a/mercurial/hgweb/hgwebdir_mod.py Thu Mar 27 12:52:41 2008 -0700 +++ b/mercurial/hgweb/hgwebdir_mod.py Mon Mar 24 18:18:39 2008 +0100 @@ -6,7 +6,7 @@ # This software may be used and distributed according to the terms # of the GNU General Public License, incorporated herein by reference. -import os, mimetools, cStringIO +import os from mercurial.i18n import gettext as _ from mercurial.repo import RepoError from mercurial import ui, hg, util, templater, templatefilters @@ -81,17 +81,8 @@ virtual = req.env.get("PATH_INFO", "").strip('/') tmpl = self.templater(req) - try: - ctype = tmpl('mimetype', encoding=util._encoding) - ctype = templater.stringify(ctype) - except KeyError: - # old templates with inline HTTP headers? - if 'mimetype' in tmpl: - raise - header = tmpl('header', encoding=util._encoding) - header_file = cStringIO.StringIO(templater.stringify(header)) - msg = mimetools.Message(header_file, 0) - ctype = msg['content-type'] + ctype = tmpl('mimetype', encoding=util._encoding) + ctype = templater.stringify(ctype) # a static file if virtual.startswith('static/') or 'static' in req.form: @@ -255,13 +246,7 @@ def templater(self, req): def header(**map): - header = tmpl('header', encoding=util._encoding, **map) - if 'mimetype' not in tmpl: - # old template with inline HTTP headers - header_file = cStringIO.StringIO(templater.stringify(header)) - msg = mimetools.Message(header_file, 0) - header = header_file.read() - yield header + yield tmpl('header', encoding=util._encoding, **map) def footer(**map): yield tmpl("footer", **map)