py3: add b'' to regular expressions which are raw strings
authorPulkit Goyal <7895pulkit@gmail.com>
Wed, 29 Nov 2017 04:47:27 +0530
changeset 35166 25c543944bc0
parent 35165 8f6641fa7c89
child 35167 0b5716ec8500
py3: add b'' to regular expressions which are raw strings Differential Revision: https://phab.mercurial-scm.org/D1538
hgext/mq.py
mercurial/dispatch.py
mercurial/util.py
--- a/hgext/mq.py	Wed Nov 29 04:41:19 2017 +0530
+++ b/hgext/mq.py	Wed Nov 29 04:47:27 2017 +0530
@@ -565,7 +565,7 @@
                 return index
         return None
 
-    guard_re = re.compile(r'\s?#([-+][^-+# \t\r\n\f][^# \t\r\n\f]*)')
+    guard_re = re.compile(br'\s?#([-+][^-+# \t\r\n\f][^# \t\r\n\f]*)')
 
     def parseseries(self):
         self.series = []
--- a/mercurial/dispatch.py	Wed Nov 29 04:41:19 2017 +0530
+++ b/mercurial/dispatch.py	Wed Nov 29 04:47:27 2017 +0530
@@ -404,7 +404,7 @@
     # tokenize each argument into exactly one word.
     replacemap['"$@"'] = ' '.join(util.shellquote(arg) for arg in args)
     # escape '\$' for regex
-    regex = '|'.join(replacemap.keys()).replace('$', r'\$')
+    regex = '|'.join(replacemap.keys()).replace('$', br'\$')
     r = re.compile(regex)
     return r.sub(lambda x: replacemap[x.group()], cmd)
 
@@ -449,7 +449,7 @@
                                  "of %i variable in alias '%s' definition."
                                  % (int(m.groups()[0]), self.name))
                         return ''
-                cmd = re.sub(r'\$(\d+|\$)', _checkvar, self.definition[1:])
+                cmd = re.sub(br'\$(\d+|\$)', _checkvar, self.definition[1:])
                 cmd = aliasinterpolate(self.name, args, cmd)
                 return ui.system(cmd, environ=env,
                                  blockedtag='alias_%s' % self.name)
--- a/mercurial/util.py	Wed Nov 29 04:41:19 2017 +0530
+++ b/mercurial/util.py	Wed Nov 29 04:47:27 2017 +0530
@@ -2667,7 +2667,7 @@
         else:
             prefix_char = prefix
         mapping[prefix_char] = prefix_char
-    r = remod.compile(r'%s(%s)' % (prefix, patterns))
+    r = remod.compile(br'%s(%s)' % (prefix, patterns))
     return r.sub(lambda x: fn(mapping[x.group()[1:]]), s)
 
 def getport(port):