[PATCH 07 of 10 py3] revsetlang: slice out single bytes instead of indexing
Augie Fackler
raf at durin42.com
Sun Mar 12 14:57:47 EDT 2017
# HG changeset patch
# User Augie Fackler <augie at google.com>
# Date 1489297619 18000
# Sun Mar 12 00:46:59 2017 -0500
# Node ID 7f013bdcdbddcc8ed86dcb373e88f6956bcbdd51
# Parent 30c4b444e0beaea64ab35b594bb976bafba9aa34
revsetlang: slice out single bytes instead of indexing
For portability with Python 3.
diff --git a/mercurial/revsetlang.py b/mercurial/revsetlang.py
--- a/mercurial/revsetlang.py
+++ b/mercurial/revsetlang.py
@@ -96,7 +96,7 @@ def tokenize(program, lookup=None, symin
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 @@ def tokenize(program, lookup=None, symin
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 @@ def tokenize(program, lookup=None, symin
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
More information about the Mercurial-devel
mailing list