match: slice over bytes to get the byteschr instead of ascii value
authorPulkit Goyal <7895pulkit@gmail.com>
Thu, 16 Mar 2017 08:03:51 +0530
changeset 31421 5c9cda37d7f6
parent 31420 40704098853f
child 31422 2e38a88bbc6c
match: slice over bytes to get the byteschr instead of ascii value
mercurial/match.py
--- 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 == '{':