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

login
register
mail settings
Submitter Pulkit Goyal
Date March 16, 2017, 4:13 a.m.
Message ID <db48c50cb5831c7c1265.1489637598@pulkit-goyal>
Download mbox | patch
Permalink /patch/19376/
State Accepted
Headers show

Comments

Pulkit Goyal - March 16, 2017, 4:13 a.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@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
via Mercurial-devel - March 16, 2017, 5:20 a.m.
On Wed, Mar 15, 2017 at 9:13 PM, Pulkit Goyal <7895pulkit@gmail.com> wrote:
> # HG changeset patch
> # User Pulkit Goyal <7895pulkit@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

I've queued up to here, thanks.

Patch

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 == '{':