comparison contrib/check-code.py @ 47635:752109dc2fb7

check-code: add a rules to catch os.path.abspath All previous usages have been migrated. So let us add a check-code rules to catch future usages. We restrict it to mercurial/ and hgext/ because multiple other script never depends on Mercurial modules. Differential Revision: https://phab.mercurial-scm.org/D11072
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Sat, 10 Jul 2021 13:46:35 +0200
parents 9b1710c50230
children 142a76127e3a
comparison
equal deleted inserted replaced
47634:352ada3aab70 47635:752109dc2fb7
541 ((?P<quote>('''|\"\"\"|(?<!')'(?!')|(?<!")"(?!"))) 541 ((?P<quote>('''|\"\"\"|(?<!')'(?!')|(?<!")"(?!")))
542 (?P<text>(([^\\]|\\.)*?)) 542 (?P<text>(([^\\]|\\.)*?))
543 (?P=quote))""", 543 (?P=quote))""",
544 reppython, 544 reppython,
545 ), 545 ),
546 ]
547
548 # pattern only for mercurial and extensions
549 core_py_pats = [
550 [
551 # Windows tend to get confused about capitalization of the drive letter
552 #
553 # see mercurial.windows.abspath for details
554 (
555 r'os\.path\.abspath',
556 "use util.abspath instead (windows)",
557 r'#.*re-exports',
558 ),
559 ],
560 # warnings
561 [],
546 ] 562 ]
547 563
548 # filters to convert normal *.py files 564 # filters to convert normal *.py files
549 pyfilters = [] + commonpyfilters 565 pyfilters = [] + commonpyfilters
550 566
697 'python 3', 713 'python 3',
698 r'.*(hgext|mercurial)/(?!demandimport|policy|pycompat).*\.py', 714 r'.*(hgext|mercurial)/(?!demandimport|policy|pycompat).*\.py',
699 '', 715 '',
700 pyfilters, 716 pyfilters,
701 py3pats, 717 py3pats,
718 ),
719 (
720 'core files',
721 r'.*(hgext|mercurial)/(?!demandimport|policy|pycompat).*\.py',
722 '',
723 pyfilters,
724 core_py_pats,
702 ), 725 ),
703 ('test script', r'(.*/)?test-[^.~]*$', '', testfilters, testpats), 726 ('test script', r'(.*/)?test-[^.~]*$', '', testfilters, testpats),
704 ('c', r'.*\.[ch]$', '', cfilters, cpats), 727 ('c', r'.*\.[ch]$', '', cfilters, cpats),
705 ('unified test', r'.*\.t$', '', utestfilters, utestpats), 728 ('unified test', r'.*\.t$', '', utestfilters, utestpats),
706 ( 729 (