changeset 31421:5c9cda37d7f6

match: slice over bytes to get the byteschr instead of ascii value
author Pulkit Goyal <7895pulkit@gmail.com>
date Thu, 16 Mar 2017 08:03:51 +0530
parents 40704098853f
children 2e38a88bbc6c
files mercurial/match.py
diffstat 1 files changed, 6 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/match.py	Thu Mar 16 07:52:47 2017 +0530
+++ b/mercurial/match.py	Thu Mar 16 08:03:51 2017 +0530
@@ -493,9 +493,9 @@
     group = 0
     escape = util.re.escape
     def peek():
-        return i < n and pat[i]
+        return i < n and pat[i:i + 1]
     while i < n:
-        c = pat[i]
+        c = pat[i:i + 1]
         i += 1
         if c not in '*?[{},\\':
             res += escape(c)
@@ -513,18 +513,18 @@
             res += '.'
         elif c == '[':
             j = i
-            if j < n and pat[j] in '!]':
+            if j < n and pat[j:j + 1] in '!]':
                 j += 1
-            while j < n and pat[j] != ']':
+            while j < n and pat[j:j + 1] != ']':
                 j += 1
             if j >= n:
                 res += '\\['
             else:
                 stuff = pat[i:j].replace('\\','\\\\')
                 i = j + 1
-                if stuff[0] == '!':
+                if stuff[0:1] == '!':
                     stuff = '^' + stuff[1:]
-                elif stuff[0] == '^':
+                elif stuff[0:1] == '^':
                     stuff = '\\' + stuff
                 res = '%s[%s]' % (res, stuff)
         elif c == '{':