changeset 31364:77270ec0cdd9

revsetlang: slice out single bytes instead of indexing For portability with Python 3.
author Augie Fackler <augie@google.com>
date Sun, 12 Mar 2017 00:46:59 -0500
parents e6a2b625e0d9
children ef6888172437
files mercurial/revsetlang.py
diffstat 1 files changed, 6 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/revsetlang.py	Sun Mar 12 03:29:04 2017 -0400
+++ b/mercurial/revsetlang.py	Sun Mar 12 00:46:59 2017 -0500
@@ -96,7 +96,7 @@
 
     pos, l = 0, len(program)
     while pos < l:
-        c = program[pos]
+        c = program[pos:pos + 1]
         if c.isspace(): # skip inter-token whitespace
             pass
         elif c == ':' and program[pos:pos + 2] == '::': # look ahead carefully
@@ -114,14 +114,14 @@
               program[pos:pos + 2] in ("r'", 'r"')): # handle quoted strings
             if c == 'r':
                 pos += 1
-                c = program[pos]
+                c = program[pos:pos + 1]
                 decode = lambda x: x
             else:
                 decode = parser.unescapestr
             pos += 1
             s = pos
             while pos < l: # find closing quote
-                d = program[pos]
+                d = program[pos:pos + 1]
                 if d == '\\': # skip over escaped characters
                     pos += 2
                     continue
@@ -136,10 +136,11 @@
             s = pos
             pos += 1
             while pos < l: # find end of symbol
-                d = program[pos]
+                d = program[pos:pos + 1]
                 if d not in symletters:
                     break
-                if d == '.' and program[pos - 1] == '.': # special case for ..
+                if (d == '.'
+                    and program[pos - 1:pos] == '.'): # special case for ..
                     pos -= 1
                     break
                 pos += 1