diff contrib/testparseutil.py @ 44022:ac3cb5e05a38

cleanup: replace contiguous spaces in regex patterns with an explicit count Flagged by PyCharm, this form should be more readable. Differential Revision: https://phab.mercurial-scm.org/D7765
author Matt Harbison <matt_harbison@yahoo.com>
date Sat, 28 Dec 2019 01:12:19 -0500
parents 70d42e2ad9b4
children 89a2afe31e82
line wrap: on
line diff
--- a/contrib/testparseutil.py	Mon Dec 30 12:17:02 2019 -0500
+++ b/contrib/testparseutil.py	Sat Dec 28 01:12:19 2019 -0500
@@ -331,9 +331,9 @@
         )
         self._fileres = [
             # "cat > NAME << LIMIT" case
-            re.compile(r'  \$ \s*cat' + namepat + heredoclimitpat),
+            re.compile(r' {2}\$ \s*cat' + namepat + heredoclimitpat),
             # "cat << LIMIT > NAME" case
-            re.compile(r'  \$ \s*cat' + heredoclimitpat + namepat),
+            re.compile(r' {2}\$ \s*cat' + heredoclimitpat + namepat),
         ]
 
     def startsat(self, line):
@@ -426,7 +426,7 @@
     """
 
     _prefix = '  >>> '
-    _prefixre = re.compile(r'  (>>>|\.\.\.) ')
+    _prefixre = re.compile(r' {2}(>>>|\.\.\.) ')
 
     # If a line matches against not _prefixre but _outputre, that line
     # is "an expected output line" (= not a part of code fragment).
@@ -436,7 +436,7 @@
     # run-tests.py. But "directive line inside inline python code"
     # should be rejected by Mercurial reviewers. Therefore, this
     # regexp does not matche against such directive lines.
-    _outputre = re.compile(r'  $|  [^$]')
+    _outputre = re.compile(r' {2}$| {2}[^$]')
 
     def __init__(self):
         super(pydoctestmatcher, self).__init__("doctest style python code")
@@ -509,7 +509,7 @@
     _prefix = '  > '
 
     _startre = re.compile(
-        r'  \$ (\$PYTHON|"\$PYTHON"|python).*' + heredoclimitpat
+        r' {2}\$ (\$PYTHON|"\$PYTHON"|python).*' + heredoclimitpat
     )
 
     def __init__(self):