--- a/tests/test-command-template.t Mon Mar 10 01:01:43 2014 +0900
+++ b/tests/test-command-template.t Mon Mar 10 01:01:43 2014 +0900
@@ -1610,6 +1610,92 @@
<>\n<]>
<>\n<
+"string-escape"-ed "\x5c\x786e" becomes r"\x6e" (once) or r"n" (twice)
+
+ $ hg log -R a -r 0 --template '{if("1", "\x5c\x786e", "NG")}\n'
+ \x6e
+ $ hg log -R a -r 0 --template '{if("1", r"\x5c\x786e", "NG")}\n'
+ \x5c\x786e
+ $ hg log -R a -r 0 --template '{if("", "NG", "\x5c\x786e")}\n'
+ \x6e
+ $ hg log -R a -r 0 --template '{if("", "NG", r"\x5c\x786e")}\n'
+ \x5c\x786e
+
+ $ hg log -R a -r 2 --template '{ifeq("no perso\x6e", desc, "\x5c\x786e", "NG")}\n'
+ \x6e
+ $ hg log -R a -r 2 --template '{ifeq(r"no perso\x6e", desc, "NG", r"\x5c\x786e")}\n'
+ \x5c\x786e
+ $ hg log -R a -r 2 --template '{ifeq(desc, "no perso\x6e", "\x5c\x786e", "NG")}\n'
+ \x6e
+ $ hg log -R a -r 2 --template '{ifeq(desc, r"no perso\x6e", "NG", r"\x5c\x786e")}\n'
+ \x5c\x786e
+
+ $ hg log -R a -r 8 --template '{join(files, "\n")}\n'
+ fourth
+ second
+ third
+ $ hg log -R a -r 8 --template '{join(files, r"\n")}\n'
+ fourth\nsecond\nthird
+
+ $ hg log -R a -r 2 --template '{rstdoc("1st\n\n2nd", "htm\x6c")}'
+ <p>
+ 1st
+ </p>
+ <p>
+ 2nd
+ </p>
+ $ hg log -R a -r 2 --template '{rstdoc(r"1st\n\n2nd", "html")}'
+ <p>
+ 1st\n\n2nd
+ </p>
+ $ hg log -R a -r 2 --template '{rstdoc("1st\n\n2nd", r"htm\x6c")}'
+ 1st
+
+ 2nd
+
+ $ hg log -R a -r 2 --template '{strip(desc, "\x6e")}\n'
+ o perso
+ $ hg log -R a -r 2 --template '{strip(desc, r"\x6e")}\n'
+ no person
+ $ hg log -R a -r 2 --template '{strip("no perso\x6e", "\x6e")}\n'
+ o perso
+ $ hg log -R a -r 2 --template '{strip(r"no perso\x6e", r"\x6e")}\n'
+ no perso
+
+ $ hg log -R a -r 2 --template '{sub("\\x6e", "\x2d", desc)}\n'
+ -o perso-
+ $ hg log -R a -r 2 --template '{sub(r"\\x6e", "-", desc)}\n'
+ no person
+ $ hg log -R a -r 2 --template '{sub("n", r"\x2d", desc)}\n'
+ \x2do perso\x2d
+ $ hg log -R a -r 2 --template '{sub("n", "\x2d", "no perso\x6e")}\n'
+ -o perso-
+ $ hg log -R a -r 2 --template '{sub("n", r"\x2d", r"no perso\x6e")}\n'
+ \x2do perso\x6e
+
+ $ hg log -R a -r 8 --template '{files % "{file}\n"}'
+ fourth
+ second
+ third
+ $ hg log -R a -r 8 --template '{files % r"{file}\n"}\n'
+ fourth\nsecond\nthird\n
+
+Test string escapeing in nested expression:
+
+ $ hg log -R a -r 8 --template '{ifeq(r"\x6e", if("1", "\x5c\x786e"), join(files, "\x5c\x786e"))}\n'
+ fourth\x6esecond\x6ethird
+ $ hg log -R a -r 8 --template '{ifeq(if("1", r"\x6e"), "\x5c\x786e", join(files, "\x5c\x786e"))}\n'
+ fourth\x6esecond\x6ethird
+
+ $ hg log -R a -r 8 --template '{join(files, ifeq(branch, "default", "\x5c\x786e"))}\n'
+ fourth\x6esecond\x6ethird
+ $ hg log -R a -r 8 --template '{join(files, ifeq(branch, "default", r"\x5c\x786e"))}\n'
+ fourth\x5c\x786esecond\x5c\x786ethird
+
+ $ hg log -R a -r 3:4 --template '{rev}:{sub(if("1", "\x6e"), ifeq(branch, "foo", r"\x5c\x786e", "\x5c\x786e"), desc)}\n'
+ 3:\x6eo user, \x6eo domai\x6e
+ 4:\x5c\x786eew bra\x5c\x786ech
+
Test recursive evaluation:
$ hg init r