changeset 42674: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 74b4cd091e0d
children e9592e113c31
files contrib/byteify-strings.py
diffstat 1 files changed, 13 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/byteify-strings.py	Wed May 22 16:22:06 2019 -0700
+++ b/contrib/byteify-strings.py	Fri Aug 02 09:44:11 2019 +0200
@@ -78,9 +78,19 @@
         already been done.
 
         """
-        st = tokens[j]
-        if st.type == token.STRING and st.string.startswith(("'", '"')):
-            sysstrtokens.add(st)
+        k = j
+        currtoken = tokens[k]
+        while currtoken.type in (token.STRING, token.NEWLINE, tokenize.NL):
+            k += 1
+            if (
+                currtoken.type == token.STRING
+                and currtoken.string.startswith(("'", '"'))
+            ):
+                sysstrtokens.add(currtoken)
+            try:
+                currtoken = tokens[k]
+            except IndexError:
+                break
 
     coldelta = 0  # column increment for new opening parens
     coloffset = -1  # column offset for the current line (-1: TBD)