comparison contrib/testparseutil.py @ 41552:99b4c6d73a72

testparseutil: escape backslash in docstring 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. Differential Revision: https://phab.mercurial-scm.org/D5842
author Gregory Szorc <gregory.szorc@gmail.com>
date Mon, 04 Feb 2019 14:16:52 -0800
parents 726cfc47f17a
children 5364ba1f796f
comparison
equal deleted inserted replaced
41551:033a0f4b4a5f 41552:99b4c6d73a72
263 heredoclimitpat = br'\s*<<\s*(?P<lquote>["\']?)(?P<limit>\w+)(?P=lquote)' 263 heredoclimitpat = br'\s*<<\s*(?P<lquote>["\']?)(?P<limit>\w+)(?P=lquote)'
264 264
265 class fileheredocmatcher(embeddedmatcher): 265 class fileheredocmatcher(embeddedmatcher):
266 """Detect "cat > FILE << LIMIT" style embedded code 266 """Detect "cat > FILE << LIMIT" style embedded code
267 267
268 >>> matcher = fileheredocmatcher(b'heredoc .py file', br'[^<]+\.py') 268 >>> matcher = fileheredocmatcher(b'heredoc .py file', br'[^<]+\\.py')
269 >>> b2s(matcher.startsat(b' $ cat > file.py << EOF\\n')) 269 >>> b2s(matcher.startsat(b' $ cat > file.py << EOF\\n'))
270 ('file.py', ' > EOF\\n') 270 ('file.py', ' > EOF\\n')
271 >>> b2s(matcher.startsat(b' $ cat >>file.py <<EOF\\n')) 271 >>> b2s(matcher.startsat(b' $ cat >>file.py <<EOF\\n'))
272 ('file.py', ' > EOF\\n') 272 ('file.py', ' > EOF\\n')
273 >>> b2s(matcher.startsat(b' $ cat> \\x27any file.py\\x27<< "EOF"\\n')) 273 >>> b2s(matcher.startsat(b' $ cat> \\x27any file.py\\x27<< "EOF"\\n'))