##// END OF EJS Templates
packaging: rename hgrc.d to defaultrc for Windows config files next to the exe...
packaging: rename hgrc.d to defaultrc for Windows config files next to the exe The code and the help still says that it will read hgrc.d next to the executable. But this directory needs to exist to read the resource based config files. Otherwise even `hg version` errors out: $ /c/Program\ Files/Mercurial/hg.exe version Traceback (most recent call last): File "hg", line 43, in <module> File "mercurial\dispatch.pyc", line 110, in run File "mercurial\dispatch.pyc", line 226, in dispatch File "mercurial\ui.pyc", line 308, in load File "mercurial\rcutil.pyc", line 99, in rccomponents File "mercurial\rcutil.pyc", line 69, in default_rc_resources File "mercurial\utils\resourceutil.pyc", line 84, in contents WindowsError: [Error 3] The system cannot find the path specified: 'c:\\Program Files\\mercurial\\defaultrc\\*.*' Differential Revision: https://phab.mercurial-scm.org/D7981

File last commit:

r44089:47ef023d default
r44614:e4344e46 5.3rc1 stable
Show More
docchecker
84 lines | 1.9 KiB | text/plain | TextLexer
timeless
docchecker: introduce a way to check for poor markup...
r27730 #!/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.
Pulkit Goyal
py3: make doc/docchecker use absolute_import
r29168
Pulkit Goyal
py3: make doc/docchecker use print_function
r29169 from __future__ import absolute_import, print_function
Pulkit Goyal
py3: make doc/docchecker use absolute_import
r29168
Matt Harbison
py3: byteify docchecker...
r41042 import os
Pulkit Goyal
py3: make doc/docchecker use absolute_import
r29168 import re
timeless
docchecker: introduce a way to check for poor markup...
r27730 import sys
Matt Harbison
py3: byteify docchecker...
r41042 try:
import msvcrt
Gregory Szorc
black: blacken scripts...
r44089
Matt Harbison
py3: byteify docchecker...
r41042 msvcrt.setmode(sys.stdout.fileno(), os.O_BINARY)
msvcrt.setmode(sys.stderr.fileno(), os.O_BINARY)
except ImportError:
pass
stdout = getattr(sys.stdout, 'buffer', sys.stdout)
leadingline = re.compile(br'(^\s*)(\S.*)$')
timeless
docchecker: report context line at most once
r28810
checks = [
Gregory Szorc
black: blacken scripts...
r44089 (
br""":hg:`[^`]*'[^`]*`""",
b"""warning: please avoid nesting ' in :hg:`...`""",
),
(br'\w:hg:`', b'warning: please have a space before :hg:'),
(
br"""(?:[^a-z][^'.])hg ([^,;"`]*'(?!hg)){2}""",
b'''warning: please use " instead of ' for hg ... "..."''',
),
timeless
docchecker: report context line at most once
r28810 ]
timeless
docchecker: introduce a way to check for poor markup...
r27730
Gregory Szorc
black: blacken scripts...
r44089
timeless
docchecker: introduce a way to check for poor markup...
r27730 def check(line):
timeless
docchecker: report context line at most once
r28810 messages = []
for match, msg in checks:
if re.search(match, line):
messages.append(msg)
if messages:
Matt Harbison
py3: byteify docchecker...
r41042 stdout.write(b'%s\n' % line)
timeless
docchecker: report context line at most once
r28810 for msg in messages:
Matt Harbison
py3: byteify docchecker...
r41042 stdout.write(b'%s\n' % msg)
timeless
docchecker: introduce a way to check for poor markup...
r27730
Gregory Szorc
black: blacken scripts...
r44089
timeless
docchecker: introduce a way to check for poor markup...
r27730 def work(file):
Matt Harbison
py3: byteify docchecker...
r41042 (llead, lline) = (b'', b'')
timeless
docchecker: introduce a way to check for poor markup...
r27730
FUJIWARA Katsunori
docchecker: use indentation of 4 spaces...
r28049 for line in file:
# this section unwraps lines
match = leadingline.match(line)
if not match:
check(lline)
Matt Harbison
py3: byteify docchecker...
r41042 (llead, lline) = (b'', b'')
FUJIWARA Katsunori
docchecker: use indentation of 4 spaces...
r28049 continue
timeless
docchecker: introduce a way to check for poor markup...
r27730
FUJIWARA Katsunori
docchecker: use indentation of 4 spaces...
r28049 lead, line = match.group(1), match.group(2)
Gregory Szorc
black: blacken scripts...
r44089 if lead == llead:
if lline != b'':
Matt Harbison
py3: byteify docchecker...
r41042 lline += b' ' + line
FUJIWARA Katsunori
docchecker: use indentation of 4 spaces...
r28049 else:
lline = line
else:
check(lline)
(llead, lline) = (lead, line)
check(lline)
timeless
docchecker: introduce a way to check for poor markup...
r27730
Gregory Szorc
black: blacken scripts...
r44089
timeless
docchecker: introduce a way to check for poor markup...
r27730 def main():
FUJIWARA Katsunori
docchecker: use indentation of 4 spaces...
r28049 for f in sys.argv[1:]:
try:
Matt Harbison
py3: byteify docchecker...
r41042 with open(f, 'rb') as file:
FUJIWARA Katsunori
docchecker: use indentation of 4 spaces...
r28049 work(file)
except BaseException as e:
Matt Harbison
py3: byteify docchecker...
r41042 sys.stdout.write(r"failed to process %s: %s\n" % (f, e))
timeless
docchecker: introduce a way to check for poor markup...
r27730
Gregory Szorc
black: blacken scripts...
r44089
timeless
docchecker: introduce a way to check for poor markup...
r27730 main()