80 "Log = {desc}" expands to the first line of the changeset description. |
80 "Log = {desc}" expands to the first line of the changeset description. |
81 ''' |
81 ''' |
82 |
82 |
83 from mercurial import commands, cmdutil, context, dispatch, filelog, revlog |
83 from mercurial import commands, cmdutil, context, dispatch, filelog, revlog |
84 from mercurial import patch, localrepo, templater, templatefilters, util |
84 from mercurial import patch, localrepo, templater, templatefilters, util |
|
85 from mercurial.hgweb import webcommands |
85 from mercurial.node import * |
86 from mercurial.node import * |
86 from mercurial.i18n import _ |
87 from mercurial.i18n import _ |
87 import re, shutil, tempfile, time |
88 import re, shutil, tempfile, time |
88 |
89 |
89 commands.optionalrepo += ' kwdemo' |
90 commands.optionalrepo += ' kwdemo' |
114 if _kwtemplater.matcher(self.fname): |
115 if _kwtemplater.matcher(self.fname): |
115 # shrink keywords read from working dir |
116 # shrink keywords read from working dir |
116 kwshrunk = _kwtemplater.shrink(''.join(self.lines)) |
117 kwshrunk = _kwtemplater.shrink(''.join(self.lines)) |
117 self.lines = kwshrunk.splitlines(True) |
118 self.lines = kwshrunk.splitlines(True) |
118 |
119 |
|
120 def _kwweb_changeset(web, req, tmpl): |
|
121 '''Wraps webcommands.changeset turning off keyword expansion.''' |
|
122 _kwtemplater.matcher = util.never |
|
123 return web.changeset(tmpl, web.changectx(req)) |
|
124 |
|
125 def _kwweb_filediff(web, req, tmpl): |
|
126 '''Wraps webcommands.filediff turning off keyword expansion.''' |
|
127 _kwtemplater.matcher = util.never |
|
128 return web.filediff(tmpl, web.filectx(req)) |
|
129 |
119 def _kwdispatch_parse(ui, args): |
130 def _kwdispatch_parse(ui, args): |
120 '''Monkeypatch dispatch._parse to obtain |
131 '''Monkeypatch dispatch._parse to obtain |
121 current command and command options (global _cmd, _cmdoptions).''' |
132 current command and command options (global _cmd, _cmdoptions).''' |
122 global _cmd, _cmdoptions |
133 global _cmd, _cmdoptions |
123 _cmd, func, args, options, _cmdoptions = _dispatch_parse(ui, args) |
134 _cmd, func, args, options, _cmdoptions = _dispatch_parse(ui, args) |
124 return _cmd, func, args, options, _cmdoptions |
135 return _cmd, func, args, options, _cmdoptions |
125 |
136 |
|
137 # dispatch._parse is run before reposetup, so wrap it here |
126 dispatch._parse = _kwdispatch_parse |
138 dispatch._parse = _kwdispatch_parse |
127 |
139 |
128 |
140 |
129 class kwtemplater(object): |
141 class kwtemplater(object): |
130 ''' |
142 ''' |