Mercurial > public > mercurial-scm > hg-stable
comparison contrib/check-code.py @ 31726:be8a866a2c44
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.
author | Jun Wu <quark@fb.com> |
---|---|
date | Wed, 29 Mar 2017 16:46:57 -0700 |
parents | 6a2959acae1a |
children | 0e4f70f63aaa |
comparison
equal
deleted
inserted
replaced
31725:dea2a17cbfd0 | 31726:be8a866a2c44 |
---|---|
335 (r'^import cPickle', "don't use cPickle, use util.pickle"), | 335 (r'^import cPickle', "don't use cPickle, use util.pickle"), |
336 (r'^import pickle', "don't use pickle, use util.pickle"), | 336 (r'^import pickle', "don't use pickle, use util.pickle"), |
337 (r'^import httplib', "don't use httplib, use util.httplib"), | 337 (r'^import httplib', "don't use httplib, use util.httplib"), |
338 (r'^import BaseHTTPServer', "use util.httpserver instead"), | 338 (r'^import BaseHTTPServer', "use util.httpserver instead"), |
339 (r'\.next\(\)', "don't use .next(), use next(...)"), | 339 (r'\.next\(\)', "don't use .next(), use next(...)"), |
340 (r'([a-z]*).revision\(\1\.node\(', | |
341 "don't covert rev to node before passing to revision(nodeorrev)"), | |
340 | 342 |
341 # rules depending on implementation of repquote() | 343 # rules depending on implementation of repquote() |
342 (r' x+[xpqo%APM][\'"]\n\s+[\'"]x', | 344 (r' x+[xpqo%APM][\'"]\n\s+[\'"]x', |
343 'string join across lines with no space'), | 345 'string join across lines with no space'), |
344 (r'''(?x)ui\.(status|progress|write|note|warn)\( | 346 (r'''(?x)ui\.(status|progress|write|note|warn)\( |