[PATCH 3 of 6 py3] match: slice over bytes to get the byteschr instead of ascii value

Pulkit Goyal 7895pulkit at gmail.com
Thu Mar 16 00:13:18 EDT 2017


# HG changeset patch
# User Pulkit Goyal <7895pulkit at gmail.com>
# Date 1489631631 -19800
#      Thu Mar 16 08:03:51 2017 +0530
# Node ID db48c50cb5831c7c1265296d8d6c8d589ed41689
# Parent  40704098853f291c09687cdebd5998ea7e3f01ff
match: slice over bytes to get the byteschr instead of ascii value

diff -r 40704098853f -r db48c50cb583 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 == '{':


More information about the Mercurial-devel mailing list