D5842: testparseutil: escape backslash in docstring

indygreg (Gregory Szorc) phabricator at mercurial-scm.org
Mon Feb 4 22:47:58 UTC 2019


indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This is funky. This inline Python code is part of a docstring, which
  means the string is interpreted first. So any backslashes need double
  escaping. So even though this is already a br'', we still need to escape.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  contrib/testparseutil.py

CHANGE DETAILS

diff --git a/contrib/testparseutil.py b/contrib/testparseutil.py
--- a/contrib/testparseutil.py
+++ b/contrib/testparseutil.py
@@ -265,7 +265,7 @@
 class fileheredocmatcher(embeddedmatcher):
     """Detect "cat > FILE << LIMIT" style embedded code
 
-    >>> matcher = fileheredocmatcher(b'heredoc .py file', br'[^<]+\.py')
+    >>> matcher = fileheredocmatcher(b'heredoc .py file', br'[^<]+\\.py')
     >>> b2s(matcher.startsat(b'  $ cat > file.py << EOF\\n'))
     ('file.py', '  > EOF\\n')
     >>> b2s(matcher.startsat(b'  $ cat   >>file.py   <<EOF\\n'))



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


More information about the Mercurial-devel mailing list