##// END OF EJS Templates
tests: make test-alias.t pass with re2...
tests: make test-alias.t pass with re2 Locally, these "non-ASCII character in alias" errors don't show up, though I get them when the alias is defined at the command line rather than in an hgrc. The brokenness comes from the fact that hgrcs are parsed with regexes, and re/re2 differ in this way: $ python -c 'import re; print(re.compile("(.*)").match("aaa\xc0bbbb").groups())' ('aaa\xc0bbbb',) $ python -c 'import re2; print(re2.compile("(.*)").match("aaa\xc0bbbb").groups())' ('aaa',) Apparently re2 stops when it encounters invalid utf8 (which I suppose makes sense given that '.' matches what appears to be a codepoint rather than a byte). This is presumably a bug in hg, but not very important, so just change the test to stick to valid utf8. Differential Revision: https://phab.mercurial-scm.org/D5288

File last commit:

r29169:c9ab5a0b default
r40708:557d3509 default
Show More
docchecker
66 lines | 1.6 KiB | text/plain | TextLexer
#!/usr/bin/env python
#
# docchecker - look for problematic markup
#
# Copyright 2016 timeless <timeless@mozdev.org> and others
#
# This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version.
from __future__ import absolute_import, print_function
import re
import sys
leadingline = re.compile(r'(^\s*)(\S.*)$')
checks = [
(r""":hg:`[^`]*'[^`]*`""",
"""warning: please avoid nesting ' in :hg:`...`"""),
(r'\w:hg:`',
'warning: please have a space before :hg:'),
(r"""(?:[^a-z][^'.])hg ([^,;"`]*'(?!hg)){2}""",
'''warning: please use " instead of ' for hg ... "..."'''),
]
def check(line):
messages = []
for match, msg in checks:
if re.search(match, line):
messages.append(msg)
if messages:
print(line)
for msg in messages:
print(msg)
def work(file):
(llead, lline) = ('', '')
for line in file:
# this section unwraps lines
match = leadingline.match(line)
if not match:
check(lline)
(llead, lline) = ('', '')
continue
lead, line = match.group(1), match.group(2)
if (lead == llead):
if (lline != ''):
lline += ' ' + line
else:
lline = line
else:
check(lline)
(llead, lline) = (lead, line)
check(lline)
def main():
for f in sys.argv[1:]:
try:
with open(f) as file:
work(file)
except BaseException as e:
print("failed to process %s: %s" % (f, e))
main()