Patchwork [5,of,6] py3: add r'' to make the regex pattern bytes

login
register
mail settings
Submitter Pulkit Goyal
Date June 26, 2017, 1:24 p.m.
Message ID <9b4f630d4488873d10af.1498483486@workspace>
Download mbox | patch
Permalink /patch/21734/
State Accepted
Headers show

Comments

Pulkit Goyal - June 26, 2017, 1:24 p.m.
# HG changeset patch
# User Pulkit Goyal <7895pulkit@gmail.com>
# Date 1498340515 -19800
#      Sun Jun 25 03:11:55 2017 +0530
# Node ID 9b4f630d4488873d10af57cc28522655736df752
# Parent  a4ababd6d202fa9575020df07bd7bde1d7575203
py3: add r'' to make the regex pattern bytes
Yuya Nishihara - June 27, 2017, 12:17 a.m.
On Mon, 26 Jun 2017 18:54:46 +0530, Pulkit Goyal wrote:
> # HG changeset patch
> # User Pulkit Goyal <7895pulkit@gmail.com>
> # Date 1498340515 -19800
> #      Sun Jun 25 03:11:55 2017 +0530
> # Node ID 9b4f630d4488873d10af57cc28522655736df752
> # Parent  a4ababd6d202fa9575020df07bd7bde1d7575203
> py3: add r'' to make the regex pattern bytes

should say /r''/b''/, fixed in flight.

Patch

diff --git a/mercurial/patch.py b/mercurial/patch.py
--- a/mercurial/patch.py
+++ b/mercurial/patch.py
@@ -2735,10 +2735,10 @@ 
         if line and line[-1] in '+-':
             name, graph = line.rsplit(' ', 1)
             yield (name + ' ', '')
-            m = re.search(r'\++', graph)
+            m = re.search(br'\++', graph)
             if m:
                 yield (m.group(0), 'diffstat.inserted')
-            m = re.search(r'-+', graph)
+            m = re.search(br'-+', graph)
             if m:
                 yield (m.group(0), 'diffstat.deleted')
         else:
diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -1249,7 +1249,7 @@ 
         # prompt to start parsing. Sadly, we also can't rely on
         # choices containing spaces, ASCII, or basically anything
         # except an ampersand followed by a character.
-        m = re.match(r'(?s)(.+?)\$\$([^\$]*&[^ \$].*)', prompt)
+        m = re.match(br'(?s)(.+?)\$\$([^\$]*&[^ \$].*)', prompt)
         msg = m.group(1)
         choices = [p.strip(' ') for p in m.group(2).split('$$')]
         return (msg,
diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -2840,7 +2840,7 @@ 
             return True # remote URL
         if hasdriveletter(self.path):
             return True # absolute for our purposes - can't be joined()
-        if self.path.startswith(r'\\'):
+        if self.path.startswith(br'\\'):
             return True # Windows UNC path
         if self.path.startswith('/'):
             return True # POSIX-style