Mercurial > hg
annotate doc/docchecker @ 39270:37e56607cbb9
lfs: add a progress bar when searching for blobs to upload
The search itself can take an extreme amount of time if there are a lot of
revisions involved. I've got a local repo that took 6 minutes to push 1850
commits, and 60% of that time was spent here (there are ~70K files):
\ 58.1% wrapper.py: extractpointers line 297: pointers = extractpointers(...
| 57.7% wrapper.py: pointersfromctx line 352: for p in pointersfromctx(ct...
| 57.4% wrapper.py: pointerfromctx line 397: p = pointerfromctx(ctx, f, ...
\ 38.7% context.py: __contains__ line 368: if f not in ctx:
| 38.7% util.py: __get__ line 82: return key in self._manifest
| 38.7% context.py: _manifest line 1416: result = self.func(obj)
| 38.7% manifest.py: read line 472: return self._manifestctx.re...
\ 25.6% revlog.py: revision line 1562: text = rl.revision(self._node)
\ 12.8% revlog.py: _chunks line 2217: bins = self._chunks(chain, ...
| 12.0% revlog.py: decompressline 2112: ladd(decomp(buffer(data, ch...
\ 7.8% revlog.py: checkhash line 2232: self.checkhash(text, node, ...
| 7.8% revlog.py: hash line 2315: if node != self.hash(text, ...
| 7.8% revlog.py: hash line 2242: return hash(text, p1, p2)
\ 12.0% manifest.py: __init__ line 1565: self._data = manifestdict(t...
\ 16.8% context.py: filenode line 378: if not _islfs(fctx.filelog(...
| 15.7% util.py: __get__ line 706: return self._filelog
| 14.8% context.py: _filelog line 1416: result = self.func(obj)
| 14.8% localrepo.py: file line 629: return self._repo.file(self...
| 14.8% filelog.py: __init__ line 1134: return filelog.filelog(self...
| 14.5% revlog.py: __init__ line 24: censorable=True)
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Fri, 24 Aug 2018 17:45:46 -0400 |
parents | c9ab5a0bc7c5 |
children | 9bfbb9fc5871 |
rev | line source |
---|---|
27730
ed86fb2a4187
docchecker: introduce a way to check for poor markup
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
1 #!/usr/bin/env python |
ed86fb2a4187
docchecker: introduce a way to check for poor markup
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
2 # |
ed86fb2a4187
docchecker: introduce a way to check for poor markup
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
3 # docchecker - look for problematic markup |
ed86fb2a4187
docchecker: introduce a way to check for poor markup
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
4 # |
ed86fb2a4187
docchecker: introduce a way to check for poor markup
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
5 # Copyright 2016 timeless <timeless@mozdev.org> and others |
ed86fb2a4187
docchecker: introduce a way to check for poor markup
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
6 # |
ed86fb2a4187
docchecker: introduce a way to check for poor markup
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
7 # This software may be used and distributed according to the terms of the |
ed86fb2a4187
docchecker: introduce a way to check for poor markup
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
8 # GNU General Public License version 2 or any later version. |
29168
8f2805ce93d9
py3: make doc/docchecker use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28811
diff
changeset
|
9 |
29169
c9ab5a0bc7c5
py3: make doc/docchecker use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
29168
diff
changeset
|
10 from __future__ import absolute_import, print_function |
29168
8f2805ce93d9
py3: make doc/docchecker use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28811
diff
changeset
|
11 |
8f2805ce93d9
py3: make doc/docchecker use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28811
diff
changeset
|
12 import re |
27730
ed86fb2a4187
docchecker: introduce a way to check for poor markup
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
13 import sys |
ed86fb2a4187
docchecker: introduce a way to check for poor markup
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
14 |
ed86fb2a4187
docchecker: introduce a way to check for poor markup
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
15 leadingline = re.compile(r'(^\s*)(\S.*)$') |
28810
9934362978e1
docchecker: report context line at most once
timeless <timeless@mozdev.org>
parents:
28049
diff
changeset
|
16 |
9934362978e1
docchecker: report context line at most once
timeless <timeless@mozdev.org>
parents:
28049
diff
changeset
|
17 checks = [ |
9934362978e1
docchecker: report context line at most once
timeless <timeless@mozdev.org>
parents:
28049
diff
changeset
|
18 (r""":hg:`[^`]*'[^`]*`""", |
9934362978e1
docchecker: report context line at most once
timeless <timeless@mozdev.org>
parents:
28049
diff
changeset
|
19 """warning: please avoid nesting ' in :hg:`...`"""), |
9934362978e1
docchecker: report context line at most once
timeless <timeless@mozdev.org>
parents:
28049
diff
changeset
|
20 (r'\w:hg:`', |
9934362978e1
docchecker: report context line at most once
timeless <timeless@mozdev.org>
parents:
28049
diff
changeset
|
21 'warning: please have a space before :hg:'), |
28811
1a623585a658
docchecker: try to reject single quotes
timeless <timeless@mozdev.org>
parents:
28810
diff
changeset
|
22 (r"""(?:[^a-z][^'.])hg ([^,;"`]*'(?!hg)){2}""", |
1a623585a658
docchecker: try to reject single quotes
timeless <timeless@mozdev.org>
parents:
28810
diff
changeset
|
23 '''warning: please use " instead of ' for hg ... "..."'''), |
28810
9934362978e1
docchecker: report context line at most once
timeless <timeless@mozdev.org>
parents:
28049
diff
changeset
|
24 ] |
27730
ed86fb2a4187
docchecker: introduce a way to check for poor markup
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
25 |
ed86fb2a4187
docchecker: introduce a way to check for poor markup
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
26 def check(line): |
28810
9934362978e1
docchecker: report context line at most once
timeless <timeless@mozdev.org>
parents:
28049
diff
changeset
|
27 messages = [] |
9934362978e1
docchecker: report context line at most once
timeless <timeless@mozdev.org>
parents:
28049
diff
changeset
|
28 for match, msg in checks: |
9934362978e1
docchecker: report context line at most once
timeless <timeless@mozdev.org>
parents:
28049
diff
changeset
|
29 if re.search(match, line): |
9934362978e1
docchecker: report context line at most once
timeless <timeless@mozdev.org>
parents:
28049
diff
changeset
|
30 messages.append(msg) |
9934362978e1
docchecker: report context line at most once
timeless <timeless@mozdev.org>
parents:
28049
diff
changeset
|
31 if messages: |
28049
c00f67c15c5a
docchecker: use indentation of 4 spaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28048
diff
changeset
|
32 print(line) |
28810
9934362978e1
docchecker: report context line at most once
timeless <timeless@mozdev.org>
parents:
28049
diff
changeset
|
33 for msg in messages: |
9934362978e1
docchecker: report context line at most once
timeless <timeless@mozdev.org>
parents:
28049
diff
changeset
|
34 print(msg) |
27730
ed86fb2a4187
docchecker: introduce a way to check for poor markup
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
35 |
ed86fb2a4187
docchecker: introduce a way to check for poor markup
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
36 def work(file): |
28049
c00f67c15c5a
docchecker: use indentation of 4 spaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28048
diff
changeset
|
37 (llead, lline) = ('', '') |
27730
ed86fb2a4187
docchecker: introduce a way to check for poor markup
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
38 |
28049
c00f67c15c5a
docchecker: use indentation of 4 spaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28048
diff
changeset
|
39 for line in file: |
c00f67c15c5a
docchecker: use indentation of 4 spaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28048
diff
changeset
|
40 # this section unwraps lines |
c00f67c15c5a
docchecker: use indentation of 4 spaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28048
diff
changeset
|
41 match = leadingline.match(line) |
c00f67c15c5a
docchecker: use indentation of 4 spaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28048
diff
changeset
|
42 if not match: |
c00f67c15c5a
docchecker: use indentation of 4 spaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28048
diff
changeset
|
43 check(lline) |
c00f67c15c5a
docchecker: use indentation of 4 spaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28048
diff
changeset
|
44 (llead, lline) = ('', '') |
c00f67c15c5a
docchecker: use indentation of 4 spaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28048
diff
changeset
|
45 continue |
27730
ed86fb2a4187
docchecker: introduce a way to check for poor markup
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
46 |
28049
c00f67c15c5a
docchecker: use indentation of 4 spaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28048
diff
changeset
|
47 lead, line = match.group(1), match.group(2) |
c00f67c15c5a
docchecker: use indentation of 4 spaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28048
diff
changeset
|
48 if (lead == llead): |
c00f67c15c5a
docchecker: use indentation of 4 spaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28048
diff
changeset
|
49 if (lline != ''): |
c00f67c15c5a
docchecker: use indentation of 4 spaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28048
diff
changeset
|
50 lline += ' ' + line |
c00f67c15c5a
docchecker: use indentation of 4 spaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28048
diff
changeset
|
51 else: |
c00f67c15c5a
docchecker: use indentation of 4 spaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28048
diff
changeset
|
52 lline = line |
c00f67c15c5a
docchecker: use indentation of 4 spaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28048
diff
changeset
|
53 else: |
c00f67c15c5a
docchecker: use indentation of 4 spaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28048
diff
changeset
|
54 check(lline) |
c00f67c15c5a
docchecker: use indentation of 4 spaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28048
diff
changeset
|
55 (llead, lline) = (lead, line) |
c00f67c15c5a
docchecker: use indentation of 4 spaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28048
diff
changeset
|
56 check(lline) |
27730
ed86fb2a4187
docchecker: introduce a way to check for poor markup
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
57 |
ed86fb2a4187
docchecker: introduce a way to check for poor markup
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
58 def main(): |
28049
c00f67c15c5a
docchecker: use indentation of 4 spaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28048
diff
changeset
|
59 for f in sys.argv[1:]: |
c00f67c15c5a
docchecker: use indentation of 4 spaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28048
diff
changeset
|
60 try: |
c00f67c15c5a
docchecker: use indentation of 4 spaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28048
diff
changeset
|
61 with open(f) as file: |
c00f67c15c5a
docchecker: use indentation of 4 spaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28048
diff
changeset
|
62 work(file) |
c00f67c15c5a
docchecker: use indentation of 4 spaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28048
diff
changeset
|
63 except BaseException as e: |
c00f67c15c5a
docchecker: use indentation of 4 spaces
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
28048
diff
changeset
|
64 print("failed to process %s: %s" % (f, e)) |
27730
ed86fb2a4187
docchecker: introduce a way to check for poor markup
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
65 |
ed86fb2a4187
docchecker: introduce a way to check for poor markup
timeless <timeless@mozdev.org>
parents:
diff
changeset
|
66 main() |