sapling/tests/test-check-code.t
Jun Wu 5dda7e9e48 check-code: detect r.revision(r.node(rev))
revlog.revision takes either node or rev, but taking a rev is more
efficient, because converting rev to node is just a seek and read.
That's cheaper than converting node to rev, which may require O(n) walk in
revlog index for the first times, and then triggering building the radix
tree index. Even with the radix tree built, rev -> node is still faster than
node -> rev because the radix tree requires more jumps in memory.

So r.revision(r.node(rev)) should be changed to r.revision(rev). This patch
adds a check-code rule to detect that.
2017-03-29 16:46:57 -07:00

81 lines
3.4 KiB
Raku

#require test-repo
$ . "$TESTDIR/helpers-testrepo.sh"
$ check_code="$TESTDIR"/../contrib/check-code.py
$ cd "$TESTDIR"/..
New errors are not allowed. Warnings are strongly discouraged.
(The writing "no-che?k-code" is for not skipping this file when checking.)
$ hg locate -X contrib/python-zstandard -X hgext/fsmonitor/pywatchman |
> sed 's-\\-/-g' | xargs "$check_code" --warnings --per-file=0 || false
contrib/perf.py:859:
> r.revision(r.node(x))
don't covert rev to node before passing to revision(nodeorrev)
Skipping i18n/polib.py it has no-che?k-code (glob)
mercurial/bundlerepo.py:117:
> return mdiff.textdiff(self.revision(self.node(rev1)),
don't covert rev to node before passing to revision(nodeorrev)
mercurial/bundlerepo.py:118:
> self.revision(self.node(rev2)))
don't covert rev to node before passing to revision(nodeorrev)
mercurial/demandimport.py:312:
> if os.environ.get('HGDEMANDIMPORT') != 'disable':
use encoding.environ instead (py3)
mercurial/encoding.py:54:
> environ = os.environ
use encoding.environ instead (py3)
mercurial/encoding.py:56:
> environ = os.environb
use encoding.environ instead (py3)
mercurial/encoding.py:61:
> for k, v in os.environ.items())
use encoding.environ instead (py3)
mercurial/encoding.py:221:
> for k, v in os.environ.items())
use encoding.environ instead (py3)
Skipping mercurial/httpclient/__init__.py it has no-che?k-code (glob)
Skipping mercurial/httpclient/_readers.py it has no-che?k-code (glob)
mercurial/policy.py:46:
> if 'HGMODULEPOLICY' in os.environ:
use encoding.environ instead (py3)
mercurial/policy.py:47:
> policy = os.environ['HGMODULEPOLICY'].encode('utf-8')
use encoding.environ instead (py3)
mercurial/policy.py:49:
> policy = os.environ.get('HGMODULEPOLICY', policy)
use encoding.environ instead (py3)
mercurial/revlog.py:441:
> t = self.revision(self.node(rev))
don't covert rev to node before passing to revision(nodeorrev)
mercurial/revlog.py:1599:
> basetext = self.revision(self.node(baserev), _df=fh, raw=raw)
don't covert rev to node before passing to revision(nodeorrev)
mercurial/revlog.py:1631:
> ptext = self.revision(self.node(rev), _df=fh)
don't covert rev to node before passing to revision(nodeorrev)
Skipping mercurial/statprof.py it has no-che?k-code (glob)
mercurial/unionrepo.py:93:
> return mdiff.textdiff(self.revision(self.node(rev1)),
don't covert rev to node before passing to revision(nodeorrev)
mercurial/unionrepo.py:94:
> self.revision(self.node(rev2)))
don't covert rev to node before passing to revision(nodeorrev)
[1]
@commands in debugcommands.py should be in alphabetical order.
>>> import re
>>> commands = []
>>> with open('mercurial/debugcommands.py', 'rb') as fh:
... for line in fh:
... m = re.match("^@command\('([a-z]+)", line)
... if m:
... commands.append(m.group(1))
>>> scommands = list(sorted(commands))
>>> for i, command in enumerate(scommands):
... if command != commands[i]:
... print('commands in debugcommands.py not sorted; first differing '
... 'command is %s; expected %s' % (commands[i], command))
... break