hgkw/keyword.py
branch0.9.2compat
changeset 399 5e1faca15e81
parent 397 db7cc16560d4
child 400 4a28faccdb18
--- a/hgkw/keyword.py	Sun Feb 10 01:28:16 2008 +0100
+++ b/hgkw/keyword.py	Sun Feb 10 14:57:48 2008 +0100
@@ -158,6 +158,48 @@
     pass
 
 try:
+    from mercurial.hgweb import webcommands
+
+    def _kwweb_changeset(web, req, tmpl):
+        '''Wraps webcommands.changeset turning off keyword expansion.'''
+        try:
+            _kwtemplater.matcher = util.never
+        except AttributeError:
+            pass
+        return web.changeset(tmpl, web.changectx(req))
+
+    def _kwweb_filediff(web, req, tmpl):
+        '''Wraps webcommands.filediff turning off keyword expansion.'''
+        try:
+            _kwtemplater.matcher = util.never
+        except AttributeError:
+            pass
+        return web.filediff(tmpl, web.filectx(req))
+
+    webcommands.changeset = webcommands.rev = _kwweb_changeset
+    webcommands.filediff = webcommands.diff = _kwweb_filediff
+
+except ImportError:
+    from mercurial.hgweb.hgweb_mod import hgweb
+
+    def _kwweb_changeset(self, req):
+        try:
+            _kwtemplater.matcher = util.never
+        except AttributeError:
+            pass
+        req.write(self.changeset(self.changectx(req)))
+
+    def _kwweb_filediff(self, req):
+        try:
+            _kwtemplater.matcher = util.never
+        except AttributeError:
+            pass
+        req.write(self.filediff(self.filectx(req)))
+
+    hgweb.do_changeset = hgweb.do_rev = _kwweb_changeset
+    hgweb.do_filediff = hgweb.do_diff = _kwweb_filediff
+
+try:
     # templatefilters module introduced in 9f1e6ab76069
     from mercurial import templatefilters
     template_filters = templatefilters.filters