##// END OF EJS Templates
bookmarks: cache reverse mapping (issue5868)...
bookmarks: cache reverse mapping (issue5868) I chose a simpler implementation. If the initial cost of building reverse mapping is significant, we'll have to move it under @propertycache. The nodemap could be a dict of sets, but I think keeping a sorted list is better since each node is likely to have zero/one bookmark. Micro-benchmark with 1001 bookmarks and 1001 revisions: $ for n in `seq 0 1000`; do touch $n; hg book book$n; hg ci -qAm$n; done $ hg bookmarks --time > /dev/null (orig) time: real 0.040 secs (user 0.050+0.000 sys 0.000+0.000) (new) time: real 0.040 secs (user 0.040+0.000 sys 0.010+0.000) $ hg log -T '{bookmarks}\n' --time > /dev/null (orig) time: real 0.160 secs (user 0.160+0.000 sys 0.000+0.000) (new) time: real 0.090 secs (user 0.100+0.000 sys 0.000+0.000)

File last commit:

r29169:c9ab5a0b default
r37869:04ceb267 @26 default
Show More
docchecker
66 lines | 1.6 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
import re
timeless
docchecker: introduce a way to check for poor markup...
r27730 import sys
leadingline = re.compile(r'(^\s*)(\S.*)$')
timeless
docchecker: report context line at most once
r28810
checks = [
(r""":hg:`[^`]*'[^`]*`""",
"""warning: please avoid nesting ' in :hg:`...`"""),
(r'\w:hg:`',
'warning: please have a space before :hg:'),
timeless
docchecker: try to reject single quotes
r28811 (r"""(?:[^a-z][^'.])hg ([^,;"`]*'(?!hg)){2}""",
'''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
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:
FUJIWARA Katsunori
docchecker: use indentation of 4 spaces...
r28049 print(line)
timeless
docchecker: report context line at most once
r28810 for msg in messages:
print(msg)
timeless
docchecker: introduce a way to check for poor markup...
r27730
def work(file):
FUJIWARA Katsunori
docchecker: use indentation of 4 spaces...
r28049 (llead, lline) = ('', '')
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)
(llead, lline) = ('', '')
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)
if (lead == llead):
if (lline != ''):
lline += ' ' + line
else:
lline = line
else:
check(lline)
(llead, lline) = (lead, line)
check(lline)
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:
with open(f) as file:
work(file)
except BaseException as e:
print("failed to process %s: %s" % (f, e))
timeless
docchecker: introduce a way to check for poor markup...
r27730
main()