[PATCH 1 of 2] templater: remove noop calls of parsestring(s, quoted=False) (API)
Yuya Nishihara
yuya at tcha.org
Thu May 7 22:35:49 UTC 2015
# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1430701263 -32400
# Mon May 04 10:01:03 2015 +0900
# Node ID 700144f73e6b4fef8a8ef77e767572ddb70d3aa6
# Parent 17ba4ccd20b48511b3d06ab47fb1b2faf31410d7
templater: remove noop calls of parsestring(s, quoted=False) (API)
Since db7463aa080f, parsestring(s, quoted=False) just returns s.
diff --git a/hgext/bugzilla.py b/hgext/bugzilla.py
--- a/hgext/bugzilla.py
+++ b/hgext/bugzilla.py
@@ -279,7 +279,7 @@ All the above add a comment to the Bugzi
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 @@ class bugzilla(object):
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 --git a/hgext/churn.py b/hgext/churn.py
--- a/hgext/churn.py
+++ b/hgext/churn.py
@@ -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 @@ command = cmdutil.command(cmdtable)
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 --git a/hgext/hgcia.py b/hgext/hgcia.py
--- a/hgext/hgcia.py
+++ b/hgext/hgcia.py
@@ -43,7 +43,7 @@ configure it, set the following options
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 @@ class hgcia(object):
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 --git a/hgext/keyword.py b/hgext/keyword.py
--- a/hgext/keyword.py
+++ b/hgext/keyword.py
@@ -83,7 +83,7 @@ like CVS' $Log$, are not supported. A ke
'''
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 @@ class kwtemplater(object):
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 --git a/hgext/notify.py b/hgext/notify.py
--- a/hgext/notify.py
+++ b/hgext/notify.py
@@ -138,7 +138,7 @@ import email, socket, time
# 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 @@ class notifier(object):
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 --git a/mercurial/cmdutil.py b/mercurial/cmdutil.py
--- a/mercurial/cmdutil.py
+++ b/mercurial/cmdutil.py
@@ -1445,7 +1445,7 @@ def gettemplate(ui, tmpl, style):
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 @@ def gettemplate(ui, tmpl, style):
try:
tmpl = templater.parsestring(t)
except SyntaxError:
- tmpl = templater.parsestring(t, quoted=False)
+ tmpl = t
return tmpl, None
if tmpl == 'list':
diff --git a/mercurial/filemerge.py b/mercurial/filemerge.py
--- a/mercurial/filemerge.py
+++ b/mercurial/filemerge.py
@@ -354,7 +354,6 @@ def _formatlabels(repo, fcd, fco, fca, l
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 --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -618,14 +618,11 @@ def _flatten(thing):
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'))
- return s[1:-1]
-
- return s
+def parsestring(s):
+ '''unwrap quotes'''
+ if len(s) < 2 or s[0] != s[-1]:
+ raise SyntaxError(_('unmatched quotes'))
+ return s[1:-1]
class engine(object):
'''template expansion engine.
More information about the Mercurial-devel
mailing list