Mercurial > public > mercurial-scm > hg
comparison mercurial/templater.py @ 25780:8b900b937e1c
templater: respect stop position while parsing template string
It has no effect now because stop is len(tmpl).
author | Yuya Nishihara <yuya@tcha.org> |
---|---|
date | Mon, 15 Jun 2015 23:00:42 +0900 |
parents | c1cac25ad1a6 |
children | 82c918509ef5 |
comparison
equal
deleted
inserted
replaced
25779:cd842821db2c | 25780:8b900b937e1c |
---|---|
130 def compiletemplate(tmpl, context): | 130 def compiletemplate(tmpl, context): |
131 parsed = [] | 131 parsed = [] |
132 pos, stop = 0, len(tmpl) | 132 pos, stop = 0, len(tmpl) |
133 p = parser.parser(elements) | 133 p = parser.parser(elements) |
134 while pos < stop: | 134 while pos < stop: |
135 n = tmpl.find('{', pos) | 135 n = tmpl.find('{', pos, stop) |
136 if n < 0: | 136 if n < 0: |
137 parsed.append(('string', tmpl[pos:])) | 137 parsed.append(('string', tmpl[pos:stop])) |
138 pos = stop | |
138 break | 139 break |
139 bs = (n - pos) - len(tmpl[pos:n].rstrip('\\')) | 140 bs = (n - pos) - len(tmpl[pos:n].rstrip('\\')) |
140 if bs % 2 == 1: | 141 if bs % 2 == 1: |
141 # escaped (e.g. '\{', '\\\{', but not '\\{') | 142 # escaped (e.g. '\{', '\\\{', but not '\\{') |
142 parsed.append(('string', (tmpl[pos:n - 1] + "{"))) | 143 parsed.append(('string', (tmpl[pos:n - 1] + "{"))) |