[PATCH 4 of 5] templater: drop strtoken argument from compiletemplate()

Yuya Nishihara yuya at tcha.org
Tue Jun 16 10:10:39 CDT 2015


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1434194632 -32400
#      Sat Jun 13 20:23:52 2015 +0900
# Node ID 84be213e8d69a915311f0a852fce13792290cc66
# Parent  2500c86c6c99255184db25ee60eaaf92604b20a5
templater: drop strtoken argument from compiletemplate()

There's no "rawstring" template now.

diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -93,23 +93,23 @@ def tokenizer(data):
         pos += 1
     yield ('end', None, pos)
 
-def compiletemplate(tmpl, context, strtoken="string"):
+def compiletemplate(tmpl, context):
     parsed = []
     pos, stop = 0, len(tmpl)
     p = parser.parser(tokenizer, elements)
     while pos < stop:
         n = tmpl.find('{', pos)
         if n < 0:
-            parsed.append((strtoken, tmpl[pos:]))
+            parsed.append(('string', tmpl[pos:]))
             break
         bs = (n - pos) - len(tmpl[pos:n].rstrip('\\'))
-        if strtoken == 'string' and bs % 2 == 1:
-            # escaped (e.g. '\{', '\\\{', but not '\\{' nor r'\{')
-            parsed.append((strtoken, (tmpl[pos:n - 1] + "{")))
+        if bs % 2 == 1:
+            # escaped (e.g. '\{', '\\\{', but not '\\{')
+            parsed.append(('string', (tmpl[pos:n - 1] + "{")))
             pos = n + 1
             continue
         if n > pos:
-            parsed.append((strtoken, tmpl[pos:n]))
+            parsed.append(('string', tmpl[pos:n]))
 
         pd = [tmpl, n + 1, stop]
         parseres, pos = p.parse(pd)


More information about the Mercurial-devel mailing list