# HG changeset patch # User Yuya Nishihara # Date 1430701263 -32400 # Node ID fd7287f0b43cb83b024de860192d04268aecb50c # Parent fb9b7b937b3e41418be9c50fb735c0afb89f4246 templater: remove noop calls of parsestring(s, quoted=False) (API) Since db7463aa080f, parsestring(s, quoted=False) just returns s. diff -r fb9b7b937b3e -r fd7287f0b43c hgext/bugzilla.py --- a/hgext/bugzilla.py Tue Apr 14 12:45:15 2015 -0700 +++ b/hgext/bugzilla.py Mon May 04 10:01:03 2015 +0900 @@ -279,7 +279,7 @@ from mercurial.i18n import _ from mercurial.node import short -from mercurial import cmdutil, mail, templater, util +from mercurial import cmdutil, mail, util import re, time, urlparse, xmlrpclib testedwith = 'internal' @@ -876,8 +876,6 @@ if not mapfile and not tmpl: tmpl = _('changeset {node|short} in repo {root} refers ' 'to bug {bug}.\ndetails:\n\t{desc|tabindent}') - if tmpl: - tmpl = templater.parsestring(tmpl, quoted=False) t = cmdutil.changeset_templater(self.ui, self.repo, False, None, tmpl, mapfile, False) self.ui.pushbuffer() diff -r fb9b7b937b3e -r fd7287f0b43c hgext/churn.py --- a/hgext/churn.py Tue Apr 14 12:45:15 2015 -0700 +++ b/hgext/churn.py Mon May 04 10:01:03 2015 +0900 @@ -9,7 +9,7 @@ '''command to display statistics about repository history''' from mercurial.i18n import _ -from mercurial import patch, cmdutil, scmutil, util, templater, commands +from mercurial import patch, cmdutil, scmutil, util, commands from mercurial import encoding import os import time, datetime @@ -19,7 +19,6 @@ testedwith = 'internal' def maketemplater(ui, repo, tmpl): - tmpl = templater.parsestring(tmpl, quoted=False) try: t = cmdutil.changeset_templater(ui, repo, False, None, tmpl, None, False) diff -r fb9b7b937b3e -r fd7287f0b43c hgext/hgcia.py --- a/hgext/hgcia.py Tue Apr 14 12:45:15 2015 -0700 +++ b/hgext/hgcia.py Mon May 04 10:01:03 2015 +0900 @@ -43,7 +43,7 @@ from mercurial.i18n import _ from mercurial.node import bin, short -from mercurial import cmdutil, patch, templater, util, mail +from mercurial import cmdutil, patch, util, mail import email.Parser import socket, xmlrpclib @@ -206,7 +206,6 @@ template = self.dstemplate else: template = self.deftemplate - template = templater.parsestring(template, quoted=False) t = cmdutil.changeset_templater(self.ui, self.repo, False, None, template, style, False) self.templater = t diff -r fb9b7b937b3e -r fd7287f0b43c hgext/keyword.py --- a/hgext/keyword.py Tue Apr 14 12:45:15 2015 -0700 +++ b/hgext/keyword.py Mon May 04 10:01:03 2015 +0900 @@ -83,7 +83,7 @@ ''' from mercurial import commands, context, cmdutil, dispatch, filelog, extensions -from mercurial import localrepo, match, patch, templatefilters, templater, util +from mercurial import localrepo, match, patch, templatefilters, util from mercurial import scmutil, pathutil from mercurial.hgweb import webcommands from mercurial.i18n import _ @@ -191,8 +191,7 @@ kwmaps = self.ui.configitems('keywordmaps') if kwmaps: # override default templates - self.templates = dict((k, templater.parsestring(v, False)) - for k, v in kwmaps) + self.templates = dict(kwmaps) else: self.templates = _defaultkwmaps(self.ui) diff -r fb9b7b937b3e -r fd7287f0b43c hgext/notify.py --- a/hgext/notify.py Tue Apr 14 12:45:15 2015 -0700 +++ b/hgext/notify.py Mon May 04 10:01:03 2015 +0900 @@ -138,7 +138,7 @@ # load. This was not a problem on Python 2.7. import email.Parser from mercurial.i18n import _ -from mercurial import patch, cmdutil, templater, util, mail +from mercurial import patch, cmdutil, util, mail import fnmatch testedwith = 'internal' @@ -190,8 +190,6 @@ self.ui.config('notify', 'template')) if not mapfile and not template: template = deftemplates.get(hooktype) or single_template - if template: - template = templater.parsestring(template, quoted=False) self.t = cmdutil.changeset_templater(self.ui, self.repo, False, None, template, mapfile, False) diff -r fb9b7b937b3e -r fd7287f0b43c mercurial/cmdutil.py --- a/mercurial/cmdutil.py Tue Apr 14 12:45:15 2015 -0700 +++ b/mercurial/cmdutil.py Mon May 04 10:01:03 2015 +0900 @@ -1445,7 +1445,7 @@ try: tmpl = templater.parsestring(tmpl) except SyntaxError: - tmpl = templater.parsestring(tmpl, quoted=False) + pass return tmpl, None else: style = util.expandpath(ui.config('ui', 'style', '')) @@ -1479,7 +1479,7 @@ try: tmpl = templater.parsestring(t) except SyntaxError: - tmpl = templater.parsestring(t, quoted=False) + tmpl = t return tmpl, None if tmpl == 'list': diff -r fb9b7b937b3e -r fd7287f0b43c mercurial/filemerge.py --- a/mercurial/filemerge.py Tue Apr 14 12:45:15 2015 -0700 +++ b/mercurial/filemerge.py Mon May 04 10:01:03 2015 +0900 @@ -354,7 +354,6 @@ ui = repo.ui template = ui.config('ui', 'mergemarkertemplate', _defaultconflictmarker) - template = templater.parsestring(template, quoted=False) tmpl = templater.templater(None, cache={'conflictmarker': template}) pad = max(len(l) for l in labels) diff -r fb9b7b937b3e -r fd7287f0b43c mercurial/templater.py --- a/mercurial/templater.py Tue Apr 14 12:45:15 2015 -0700 +++ b/mercurial/templater.py Mon May 04 10:01:03 2015 +0900 @@ -618,28 +618,25 @@ for j in _flatten(i): yield j -def parsestring(s, quoted=True): - '''unwrap quotes if quoted is True''' - if quoted: - if len(s) < 2 or s[0] != s[-1]: - raise SyntaxError(_('unmatched quotes')) - # de-backslash-ify only <\">. it is invalid syntax in non-string part of - # template, but we are likely to escape <"> in quoted string and it was - # accepted before, thanks to issue4290. <\\"> is unmodified because it - # is ambiguous and it was processed as such before 2.8.1. - # - # template result - # --------- ------------------------ - # {\"\"} parse error - # "{""}" {""} -> <> - # "{\"\"}" {""} -> <> - # {"\""} {"\""} -> <"> - # '{"\""}' {"\""} -> <"> - # "{"\""}" parse error (don't care) - q = s[0] - return s[1:-1].replace('\\\\' + q, '\\\\\\' + q).replace('\\' + q, q) - - return s +def parsestring(s): + '''unwrap quotes''' + if len(s) < 2 or s[0] != s[-1]: + raise SyntaxError(_('unmatched quotes')) + # de-backslash-ify only <\">. it is invalid syntax in non-string part of + # template, but we are likely to escape <"> in quoted string and it was + # accepted before, thanks to issue4290. <\\"> is unmodified because it + # is ambiguous and it was processed as such before 2.8.1. + # + # template result + # --------- ------------------------ + # {\"\"} parse error + # "{""}" {""} -> <> + # "{\"\"}" {""} -> <> + # {"\""} {"\""} -> <"> + # '{"\""}' {"\""} -> <"> + # "{"\""}" parse error (don't care) + q = s[0] + return s[1:-1].replace('\\\\' + q, '\\\\\\' + q).replace('\\' + q, q) class engine(object): '''template expansion engine.