##// END OF EJS Templates
templater: remove noop calls of parsestring(s, quoted=False) (API)...
Yuya Nishihara -
r24987:fd7287f0 default
parent child Browse files
Show More
@@ -279,7 +279,7 b' All the above add a comment to the Bugzi'
279
279
280 from mercurial.i18n import _
280 from mercurial.i18n import _
281 from mercurial.node import short
281 from mercurial.node import short
282 from mercurial import cmdutil, mail, templater, util
282 from mercurial import cmdutil, mail, util
283 import re, time, urlparse, xmlrpclib
283 import re, time, urlparse, xmlrpclib
284
284
285 testedwith = 'internal'
285 testedwith = 'internal'
@@ -876,8 +876,6 b' class bugzilla(object):'
876 if not mapfile and not tmpl:
876 if not mapfile and not tmpl:
877 tmpl = _('changeset {node|short} in repo {root} refers '
877 tmpl = _('changeset {node|short} in repo {root} refers '
878 'to bug {bug}.\ndetails:\n\t{desc|tabindent}')
878 'to bug {bug}.\ndetails:\n\t{desc|tabindent}')
879 if tmpl:
880 tmpl = templater.parsestring(tmpl, quoted=False)
881 t = cmdutil.changeset_templater(self.ui, self.repo,
879 t = cmdutil.changeset_templater(self.ui, self.repo,
882 False, None, tmpl, mapfile, False)
880 False, None, tmpl, mapfile, False)
883 self.ui.pushbuffer()
881 self.ui.pushbuffer()
@@ -9,7 +9,7 b''
9 '''command to display statistics about repository history'''
9 '''command to display statistics about repository history'''
10
10
11 from mercurial.i18n import _
11 from mercurial.i18n import _
12 from mercurial import patch, cmdutil, scmutil, util, templater, commands
12 from mercurial import patch, cmdutil, scmutil, util, commands
13 from mercurial import encoding
13 from mercurial import encoding
14 import os
14 import os
15 import time, datetime
15 import time, datetime
@@ -19,7 +19,6 b' command = cmdutil.command(cmdtable)'
19 testedwith = 'internal'
19 testedwith = 'internal'
20
20
21 def maketemplater(ui, repo, tmpl):
21 def maketemplater(ui, repo, tmpl):
22 tmpl = templater.parsestring(tmpl, quoted=False)
23 try:
22 try:
24 t = cmdutil.changeset_templater(ui, repo, False, None, tmpl,
23 t = cmdutil.changeset_templater(ui, repo, False, None, tmpl,
25 None, False)
24 None, False)
@@ -43,7 +43,7 b' configure it, set the following options '
43
43
44 from mercurial.i18n import _
44 from mercurial.i18n import _
45 from mercurial.node import bin, short
45 from mercurial.node import bin, short
46 from mercurial import cmdutil, patch, templater, util, mail
46 from mercurial import cmdutil, patch, util, mail
47 import email.Parser
47 import email.Parser
48
48
49 import socket, xmlrpclib
49 import socket, xmlrpclib
@@ -206,7 +206,6 b' class hgcia(object):'
206 template = self.dstemplate
206 template = self.dstemplate
207 else:
207 else:
208 template = self.deftemplate
208 template = self.deftemplate
209 template = templater.parsestring(template, quoted=False)
210 t = cmdutil.changeset_templater(self.ui, self.repo, False, None,
209 t = cmdutil.changeset_templater(self.ui, self.repo, False, None,
211 template, style, False)
210 template, style, False)
212 self.templater = t
211 self.templater = t
@@ -83,7 +83,7 b" like CVS' $Log$, are not supported. A ke"
83 '''
83 '''
84
84
85 from mercurial import commands, context, cmdutil, dispatch, filelog, extensions
85 from mercurial import commands, context, cmdutil, dispatch, filelog, extensions
86 from mercurial import localrepo, match, patch, templatefilters, templater, util
86 from mercurial import localrepo, match, patch, templatefilters, util
87 from mercurial import scmutil, pathutil
87 from mercurial import scmutil, pathutil
88 from mercurial.hgweb import webcommands
88 from mercurial.hgweb import webcommands
89 from mercurial.i18n import _
89 from mercurial.i18n import _
@@ -191,8 +191,7 b' class kwtemplater(object):'
191
191
192 kwmaps = self.ui.configitems('keywordmaps')
192 kwmaps = self.ui.configitems('keywordmaps')
193 if kwmaps: # override default templates
193 if kwmaps: # override default templates
194 self.templates = dict((k, templater.parsestring(v, False))
194 self.templates = dict(kwmaps)
195 for k, v in kwmaps)
196 else:
195 else:
197 self.templates = _defaultkwmaps(self.ui)
196 self.templates = _defaultkwmaps(self.ui)
198
197
@@ -138,7 +138,7 b' import email, socket, time'
138 # load. This was not a problem on Python 2.7.
138 # load. This was not a problem on Python 2.7.
139 import email.Parser
139 import email.Parser
140 from mercurial.i18n import _
140 from mercurial.i18n import _
141 from mercurial import patch, cmdutil, templater, util, mail
141 from mercurial import patch, cmdutil, util, mail
142 import fnmatch
142 import fnmatch
143
143
144 testedwith = 'internal'
144 testedwith = 'internal'
@@ -190,8 +190,6 b' class notifier(object):'
190 self.ui.config('notify', 'template'))
190 self.ui.config('notify', 'template'))
191 if not mapfile and not template:
191 if not mapfile and not template:
192 template = deftemplates.get(hooktype) or single_template
192 template = deftemplates.get(hooktype) or single_template
193 if template:
194 template = templater.parsestring(template, quoted=False)
195 self.t = cmdutil.changeset_templater(self.ui, self.repo, False, None,
193 self.t = cmdutil.changeset_templater(self.ui, self.repo, False, None,
196 template, mapfile, False)
194 template, mapfile, False)
197
195
@@ -1445,7 +1445,7 b' def gettemplate(ui, tmpl, style):'
1445 try:
1445 try:
1446 tmpl = templater.parsestring(tmpl)
1446 tmpl = templater.parsestring(tmpl)
1447 except SyntaxError:
1447 except SyntaxError:
1448 tmpl = templater.parsestring(tmpl, quoted=False)
1448 pass
1449 return tmpl, None
1449 return tmpl, None
1450 else:
1450 else:
1451 style = util.expandpath(ui.config('ui', 'style', ''))
1451 style = util.expandpath(ui.config('ui', 'style', ''))
@@ -1479,7 +1479,7 b' def gettemplate(ui, tmpl, style):'
1479 try:
1479 try:
1480 tmpl = templater.parsestring(t)
1480 tmpl = templater.parsestring(t)
1481 except SyntaxError:
1481 except SyntaxError:
1482 tmpl = templater.parsestring(t, quoted=False)
1482 tmpl = t
1483 return tmpl, None
1483 return tmpl, None
1484
1484
1485 if tmpl == 'list':
1485 if tmpl == 'list':
@@ -354,7 +354,6 b' def _formatlabels(repo, fcd, fco, fca, l'
354
354
355 ui = repo.ui
355 ui = repo.ui
356 template = ui.config('ui', 'mergemarkertemplate', _defaultconflictmarker)
356 template = ui.config('ui', 'mergemarkertemplate', _defaultconflictmarker)
357 template = templater.parsestring(template, quoted=False)
358 tmpl = templater.templater(None, cache={'conflictmarker': template})
357 tmpl = templater.templater(None, cache={'conflictmarker': template})
359
358
360 pad = max(len(l) for l in labels)
359 pad = max(len(l) for l in labels)
@@ -618,28 +618,25 b' def _flatten(thing):'
618 for j in _flatten(i):
618 for j in _flatten(i):
619 yield j
619 yield j
620
620
621 def parsestring(s, quoted=True):
621 def parsestring(s):
622 '''unwrap quotes if quoted is True'''
622 '''unwrap quotes'''
623 if quoted:
623 if len(s) < 2 or s[0] != s[-1]:
624 if len(s) < 2 or s[0] != s[-1]:
624 raise SyntaxError(_('unmatched quotes'))
625 raise SyntaxError(_('unmatched quotes'))
625 # de-backslash-ify only <\">. it is invalid syntax in non-string part of
626 # de-backslash-ify only <\">. it is invalid syntax in non-string part of
626 # template, but we are likely to escape <"> in quoted string and it was
627 # template, but we are likely to escape <"> in quoted string and it was
627 # accepted before, thanks to issue4290. <\\"> is unmodified because it
628 # accepted before, thanks to issue4290. <\\"> is unmodified because it
628 # is ambiguous and it was processed as such before 2.8.1.
629 # is ambiguous and it was processed as such before 2.8.1.
629 #
630 #
630 # template result
631 # template result
631 # --------- ------------------------
632 # --------- ------------------------
632 # {\"\"} parse error
633 # {\"\"} parse error
633 # "{""}" {""} -> <>
634 # "{""}" {""} -> <>
634 # "{\"\"}" {""} -> <>
635 # "{\"\"}" {""} -> <>
635 # {"\""} {"\""} -> <">
636 # {"\""} {"\""} -> <">
636 # '{"\""}' {"\""} -> <">
637 # '{"\""}' {"\""} -> <">
637 # "{"\""}" parse error (don't care)
638 # "{"\""}" parse error (don't care)
638 q = s[0]
639 q = s[0]
639 return s[1:-1].replace('\\\\' + q, '\\\\\\' + q).replace('\\' + q, q)
640 return s[1:-1].replace('\\\\' + q, '\\\\\\' + q).replace('\\' + q, q)
641
642 return s
643
640
644 class engine(object):
641 class engine(object):
645 '''template expansion engine.
642 '''template expansion engine.
General Comments 0
You need to be logged in to leave comments. Login now