comparison mercurial/templater.py @ 24987:fd7287f0b43c

templater: remove noop calls of parsestring(s, quoted=False) (API) Since db7463aa080f, parsestring(s, quoted=False) just returns s.
author Yuya Nishihara <yuya@tcha.org>
date Mon, 04 May 2015 10:01:03 +0900
parents 554d6fcc3c84
children e8ff0b09acac
comparison
equal deleted inserted replaced
24986:fb9b7b937b3e 24987:fd7287f0b43c
616 yield str(i) 616 yield str(i)
617 elif i is not None: 617 elif i is not None:
618 for j in _flatten(i): 618 for j in _flatten(i):
619 yield j 619 yield j
620 620
621 def parsestring(s, quoted=True): 621 def parsestring(s):
622 '''unwrap quotes if quoted is True''' 622 '''unwrap quotes'''
623 if quoted: 623 if len(s) < 2 or s[0] != s[-1]:
624 if len(s) < 2 or s[0] != s[-1]: 624 raise SyntaxError(_('unmatched quotes'))
625 raise SyntaxError(_('unmatched quotes')) 625 # de-backslash-ify only <\">. it is invalid syntax in non-string part of
626 # de-backslash-ify only <\">. it is invalid syntax in non-string part of 626 # template, but we are likely to escape <"> in quoted string and it was
627 # template, but we are likely to escape <"> in quoted string and it was 627 # accepted before, thanks to issue4290. <\\"> is unmodified because it
628 # accepted before, thanks to issue4290. <\\"> is unmodified because it 628 # is ambiguous and it was processed as such before 2.8.1.
629 # is ambiguous and it was processed as such before 2.8.1. 629 #
630 # 630 # template result
631 # template result 631 # --------- ------------------------
632 # --------- ------------------------ 632 # {\"\"} parse error
633 # {\"\"} parse error 633 # "{""}" {""} -> <>
634 # "{""}" {""} -> <> 634 # "{\"\"}" {""} -> <>
635 # "{\"\"}" {""} -> <> 635 # {"\""} {"\""} -> <">
636 # {"\""} {"\""} -> <"> 636 # '{"\""}' {"\""} -> <">
637 # '{"\""}' {"\""} -> <"> 637 # "{"\""}" parse error (don't care)
638 # "{"\""}" parse error (don't care) 638 q = s[0]
639 q = s[0] 639 return s[1:-1].replace('\\\\' + q, '\\\\\\' + q).replace('\\' + q, q)
640 return s[1:-1].replace('\\\\' + q, '\\\\\\' + q).replace('\\' + q, q)
641
642 return s
643 640
644 class engine(object): 641 class engine(object):
645 '''template expansion engine. 642 '''template expansion engine.
646 643
647 template expansion works like this. a map file contains key=value 644 template expansion works like this. a map file contains key=value