mercurial/templater.py
branchstable
changeset 24949 890845af1ac2
parent 24948 db7463aa080f
child 24966 554d6fcc3c84
child 25471 7298da81f5a9
--- a/mercurial/templater.py	Mon May 04 09:54:01 2015 +0900
+++ b/mercurial/templater.py	Mon May 04 10:17:34 2015 +0900
@@ -87,8 +87,9 @@
         if n < 0:
             parsed.append((strtoken, tmpl[pos:]))
             break
-        if n > 0 and tmpl[n - 1] == '\\':
-            # escaped
+        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] + "{")))
             pos = n + 1
             continue