Patchwork D6201: automation: use raw strings when there are backslashes

login
register
mail settings
Submitter phabricator
Date April 5, 2019, 1:21 a.m.
Message ID <differential-rev-PHID-DREV-7ih2hnvyzfngs3gbyr76-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/39487/
State Superseded
Headers show

Comments

phabricator - April 5, 2019, 1:21 a.m.
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Otherwise Python 3.8 complains.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6201

AFFECTED FILES
  contrib/automation/hgautomation/aws.py
  contrib/automation/hgautomation/windows.py

CHANGE DETAILS




To: indygreg, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/contrib/automation/hgautomation/windows.py b/contrib/automation/hgautomation/windows.py
--- a/contrib/automation/hgautomation/windows.py
+++ b/contrib/automation/hgautomation/windows.py
@@ -114,7 +114,7 @@ 
     commands = [
         '$ErrorActionPreference = "Stop"',
         'Repair-AuthorizedKeyPermission -FilePath %s -Confirm:$false' % path,
-        'icacls %s /remove:g "NT Service\sshd"' % path,
+        r'icacls %s /remove:g "NT Service\sshd"' % path,
     ]
 
     run_powershell(winrm_client, '\n'.join(commands))
@@ -192,7 +192,7 @@ 
     """Find path to newest file in dist/ directory matching a pattern."""
 
     res = winrm_client.execute_ps(
-        '$v = Get-ChildItem -Path C:\hgdev\src\dist -Filter "%s" '
+        r'$v = Get-ChildItem -Path C:\hgdev\src\dist -Filter "%s" '
         '| Sort-Object LastWriteTime -Descending '
         '| Select-Object -First 1\n'
         '$v.name' % pattern
@@ -270,8 +270,8 @@ 
     ``test_flags`` is a str representing extra arguments to pass to
     ``run-tests.py``.
     """
-    if not re.match('\d\.\d', python_version):
-        raise ValueError('python_version must be \d.\d; got %s' %
+    if not re.match(r'\d\.\d', python_version):
+        raise ValueError(r'python_version must be \d.\d; got %s' %
                          python_version)
 
     if arch not in ('x86', 'x64'):
diff --git a/contrib/automation/hgautomation/aws.py b/contrib/automation/hgautomation/aws.py
--- a/contrib/automation/hgautomation/aws.py
+++ b/contrib/automation/hgautomation/aws.py
@@ -118,7 +118,7 @@ 
 # and configure WinRM.
 # Inspired by the User Data script used by Packer
 # (from https://www.packer.io/intro/getting-started/build-image.html).
-WINDOWS_USER_DATA = '''
+WINDOWS_USER_DATA = r'''
 <powershell>
 
 # TODO enable this once we figure out what is failing.