Patchwork [3,of,8] py3: fix type of regex literals in subrepo.py

login
register
mail settings
Submitter Yuya Nishihara
Date Sept. 3, 2017, 2:36 p.m.
Message ID <004d163d1bbc31825c13.1504449381@mimosa>
Download mbox | patch
Permalink /patch/23642/
State Accepted
Headers show

Comments

Yuya Nishihara - Sept. 3, 2017, 2:36 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1504418483 -32400
#      Sun Sep 03 15:01:23 2017 +0900
# Node ID 004d163d1bbc31825c134eb4d43e60b11ced61ca
# Parent  03f65a976779da5cfb8adf475a01ac0e14e42761
py3: fix type of regex literals in subrepo.py

Patch

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -134,7 +134,7 @@  def state(ctx, ui):
             # However, we still want to allow back references to go
             # through unharmed, so we turn r'\\1' into r'\1'. Again,
             # extra escapes are needed because re.sub string decodes.
-            repl = re.sub(r'\\\\([0-9]+)', r'\\\1', repl)
+            repl = re.sub(br'\\\\([0-9]+)', br'\\\1', repl)
             try:
                 src = re.sub(pattern, repl, src, 1)
             except re.error as e:
@@ -1154,7 +1154,7 @@  class svnsubrepo(abstractsubrepo):
     @propertycache
     def _svnversion(self):
         output, err = self._svncommand(['--version', '--quiet'], filename=None)
-        m = re.search(r'^(\d+)\.(\d+)', output)
+        m = re.search(br'^(\d+)\.(\d+)', output)
         if not m:
             raise error.Abort(_('cannot retrieve svn tool version'))
         return (int(m.group(1)), int(m.group(2)))
@@ -1373,11 +1373,11 @@  class gitsubrepo(abstractsubrepo):
 
     @staticmethod
     def _gitversion(out):
-        m = re.search(r'^git version (\d+)\.(\d+)\.(\d+)', out)
+        m = re.search(br'^git version (\d+)\.(\d+)\.(\d+)', out)
         if m:
             return (int(m.group(1)), int(m.group(2)), int(m.group(3)))
 
-        m = re.search(r'^git version (\d+)\.(\d+)', out)
+        m = re.search(br'^git version (\d+)\.(\d+)', out)
         if m:
             return (int(m.group(1)), int(m.group(2)), 0)