Patchwork [3,of,4] py3: make set of revset operators and quotes in bytes

login
register
mail settings
Submitter Yuya Nishihara
Date March 13, 2017, 12:41 a.m.
Message ID <99d5a74ec8d5fb6396ca.1489365715@mimosa>
Download mbox | patch
Permalink /patch/19264/
State Accepted
Headers show

Comments

Yuya Nishihara - March 13, 2017, 12:41 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1489364034 25200
#      Sun Mar 12 17:13:54 2017 -0700
# Node ID 99d5a74ec8d5fb6396ca940708e4b9922d96edf6
# Parent  06527fc4ae45e3950b098a2509a6a55b4a275a2f
py3: make set of revset operators and quotes in bytes

Patch

diff --git a/mercurial/revsetlang.py b/mercurial/revsetlang.py
--- a/mercurial/revsetlang.py
+++ b/mercurial/revsetlang.py
@@ -45,6 +45,9 @@  elements = {
 
 keywords = set(['and', 'or', 'not'])
 
+_quoteletters = set(['"', "'"])
+_simpleopletters = set(pycompat.iterbytestr("():=,-|&+!~^%"))
+
 # default set of valid characters for the initial letter of symbols
 _syminitletters = set(pycompat.iterbytestr(
     string.ascii_letters.encode('ascii') +
@@ -109,9 +112,9 @@  def tokenize(program, lookup=None, symin
         elif c == '#' and program[pos:pos + 2] == '##': # look ahead carefully
             yield ('##', None, pos)
             pos += 1 # skip ahead
-        elif c in "():=,-|&+!~^%": # handle simple operators
+        elif c in _simpleopletters: # handle simple operators
             yield (c, None, pos)
-        elif (c in '"\'' or c == 'r' and
+        elif (c in _quoteletters or c == 'r' and
               program[pos:pos + 2] in ("r'", 'r"')): # handle quoted strings
             if c == 'r':
                 pos += 1