comparison contrib/byteify-strings.py @ 42701:70bd1965bd07

byteify-strings: handle multi-line strings in _ensuresysstr The current implementation did not handle calls like `repo.ui.log("first line" "other line")` correctly.
author Rapha?l Gom?s <rgomes@octobus.net>
date Fri, 02 Aug 2019 09:44:11 +0200
parents 970aaf38c3fc
children e9592e113c31
comparison
equal deleted inserted replaced
42700:74b4cd091e0d 42701:70bd1965bd07
76 76
77 Ignores tokens that are not strings. Assumes bounds checking has 77 Ignores tokens that are not strings. Assumes bounds checking has
78 already been done. 78 already been done.
79 79
80 """ 80 """
81 st = tokens[j] 81 k = j
82 if st.type == token.STRING and st.string.startswith(("'", '"')): 82 currtoken = tokens[k]
83 sysstrtokens.add(st) 83 while currtoken.type in (token.STRING, token.NEWLINE, tokenize.NL):
84 k += 1
85 if (
86 currtoken.type == token.STRING
87 and currtoken.string.startswith(("'", '"'))
88 ):
89 sysstrtokens.add(currtoken)
90 try:
91 currtoken = tokens[k]
92 except IndexError:
93 break
84 94
85 coldelta = 0 # column increment for new opening parens 95 coldelta = 0 # column increment for new opening parens
86 coloffset = -1 # column offset for the current line (-1: TBD) 96 coloffset = -1 # column offset for the current line (-1: TBD)
87 parens = [(0, 0, 0)] # stack of (line, end-column, column-offset) 97 parens = [(0, 0, 0)] # stack of (line, end-column, column-offset)
88 for i, t in enumerate(tokens): 98 for i, t in enumerate(tokens):